🔍

SharePoint CAML Query Builder

Construct XML CAML Queries visually for SharePoint REST APIs, PnP JS, CSOM, or SPFx. Add conditions, select fields, and generate the raw XML instantly.

What is CAML?

CAML (Collaborative Application Markup Language) is an XML-based language used in SharePoint to query lists and libraries. It's often required when fetching items using the CSOM, SSOM, or specific REST endpoints (like GetItems(query)).

Common Use Cases

  • Fetching list items with complex Or / And logic.
  • Performing efficient server-side filtering and ordering natively before data is sent to the client.
  • Limiting the response size manually using <RowLimit> and <ViewFields>.

Frequently Asked Questions

CAML (Collaborative Application Markup Language) is an XML-based query language used to filter, sort, and retrieve data from SharePoint lists and libraries. It's more powerful than OData $filter for complex queries involving nested AND/OR conditions, lookups, and managed metadata.

Use CAML when you need: nested AND/OR logic, lookup column filtering, managed metadata queries, Contains/BeginsWith operators, or recursive folder queries. OData $filter is simpler but cannot handle these advanced scenarios.

Yes! Send a POST request to /_api/web/lists/getbytitle('ListName')/GetItems with a CAML query in the request body. The Content-Type must be application/json;odata=verbose.

Hand-writing CAML XML is extremely error-prone. A single misplaced tag (<Eq>, <FieldRef>, <Value>) will silently return wrong results or throw cryptic SharePoint errors. This builder ensures your nodes are perfectly nested and formatted.

CAML supports: Eq (equals), Neq (not equals), Gt/Geq (greater than), Lt/Leq (less than), Contains, BeginsWith, IsNull/IsNotNull, In (multiple values), and DateRangesOverlap for calendar queries.

Use <FieldRef Name="LookupColumn" LookupId="TRUE" /> with the lookup ID value. This is one area where CAML is superior to OData, which struggles with complex lookup filtering.

Yes. PnP.js provides a .getItemsByCAMLQuery() method that accepts a CAML query string. It handles the REST API call and JSON parsing for you, making it the cleanest approach for SPFx web parts.