CAML Query Builder for SharePoint 2013/2016/Online

In this sharepoint caml query builder tutorial, we will discuss CAML as well as the free CAML query builder tool in SharePoint 2013 and how we can use the U2U CAML query builder tool step by step. Here we will discuss how to CAML query builder for SharePoint 2013/2016/Online. We can use CAML query builder for SharePoint Online and SharePoint on-premises versions.

We will see how to download and install CAML query builder for SharePoint 2016/2013/Online, how to use CAML query builder in SharePoint.

CAML Query Builder in SharePoint Online/2013/2016

CAML know as Collaborative Markup Language is an XML based language for querying and updating SharePoint objects like List and Libraries. CAML helps us retrieving items from a SharePoint list based on various conditions, we can also put order by, can also limit items returns from the query etc.

The below is a simple syntax of the CAML query:

<FieldRef Name="FieldName" />
<Value Type="DataType">Value</Value>
<FieldRef Name="FieldName" />
<FieldRef Name="FieldName" />

Here we can use various other operators like below:

Comparison OperatorsGeneral Meaning
BeginsWithBeginning with word
DateRangesOverlapcompare the dates in a recurring event with a specified DateTime value, to determine whether they overlap
calm query builder operators

Rather than writing the query manually to query sharepoint list, we can use a free tool known as CAML query builder to generate the sharepoint caml query for us.

Advantages of CAML query builder tool

We learn what is CAML? And let us see what are the advantages of CAML query builder tool.

  • We can manually write the CAML query for SharePoint, but when you will use the caml query builder, it will help us to build the query without a syntax error. Also, you can validate and see the result in the CAML query builder tool.
  • The user interface is easier to create the query in the CAML query builder.
  • CAML query builder is a free tool that you can download and install in a SharePoint server as well as a client operating system like Windows 10/8/7. From there you can connect to SharePoint Online sites.

Download & Install CAML Query Builder in SharePoint

SharePoint caml query builder is a great tool to create and test CAML queries in SharePoint. This will work with both on-premise as well as SharePoint Online. You should have Microsoft .NET Framework 4.5 installed in your machine else it will not work.

First Download the Tool from this URL and then install it. You can download “U2U Caml Query Builder for SharePoint 2013 (Standalone Edition)”.

The U2U Caml Query Builder for SharePoint will help us to query SharePoint list. Internally, this tool used the SharePoint client object model code to connect to SharePoint Online or 2013/2016 sites remotely.

How to use caml query builder

Now, we will see how to use caml query builder to connect to SharePoint On-premises as well as SharePoint Online sites.

Once installation over, when you will open the tool, it will open the Connect dialog box, through which you will be able to connect to your on-premise as well as your online environment. see fig below:

CAML Query Builder for SharePoint
download u2u caml query builder for sharepoint 2016

Here first I gave my on-premise site URL and when I connect it, it displays me all the list and libraries presented in the SharePoint site like below:

caml query in sharepoint 2013 examples
caml query in sharepoint 2013 examples

Similarly, you can also connect to a SharePoint Online site. When connecting to an online site, you have to provide the username and password. And then the URL.

Enter the URL like If you will add /SitePages/Home.aspx, it will through an error. See fig below:

CAML Query Builder for SharePoint Online
CAML Query Builder for SharePoint 2013/2016/Online

Here is my SharePoint Online, I have a list name as TestList and I want to build the query for that SharePoint list.

Building CAML Query using CAML Query Builder

Now, we will see how to build our CAML query using CAML query builder.

Now select the SharePoint Online List and then New query -> Query with View Fields as shown in the fig below

u2u caml query builder sharepoint online
u2u caml query builder sharepoint online

This will create two tabs one is Query and another one is View Fields. In the View Fields tab you can select the Columns which are you want to query using the calm query builder like below:

Here I have selected the ID, Title, and First Name SharePoint List columns and it showed me the CAML query in the Editor window.

download u2u caml query builder for sharepoint 2016
caml query builder sharepoint

Any time you can run the caml query and can see the results. It will also generate the CSOM Code and Server-side code for this which you see from the corresponding tabs.

Now let us go to the Query tab and add some filter criteria into the query.

Here I added a Filter that If Title Contains Items and then added Title equals Sharepoint item-1. You can add the Or or And condition by click on the Filter drop-down.

Add Order By in CAML Query

Similarly, If you want to add one Order by then you can click on the Add order by element button and then select the Column and the condition whether Ascending or Descending.

Then it will generate the CAML query for you in the Editor box.

u2u caml query builder download
caml query builder sharepoint 2013

If you want to use the same query in a CSOM code, then you can write like below:

using (ClientContext ctx = new ClientContext())
Web web = ctx.Web;
List list = web.Lists.GetById(new Guid("5c42def2-bd2c-4df6-bcca-359351944cd2"));
var q = new CamlQuery() { ViewXml = "<View><Query><Where><Or><Contains><FieldRef Name='Title' /><Value Type='Text'>Items</Value></Contains><Eq><FieldRef Name='Title' /><Value Type='Text'>Sharepoint item-1</Value></Eq></Or></Where><OrderBy><FieldRef Name='ID' Ascending='False' /></OrderBy></Query><ViewFields><FieldRef Name='ID' /><FieldRef Name='First_x0020_Name' /><FieldRef Name='LinkTitle' /></ViewFields><QueryOptions /></View>"};
var r = list.GetItems(q);

You may like following SharePoint CAML Query examples:


In this caml query builder online tutorial, I have explained how to download and install U2U CAML Query Builder for SharePoint. How we can use CAML query builder in SharePoint 2013/2016/Online.

Also, we checked how to use calm query builder to query SharePoint list. This is how we can use SharePoint CAML Query builder.

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.

  • >