CQL syntax rule
Reserved characters and words in CQL (Confluence)
CQL treats some characters and some words as part of its own grammar. A value that contains one of them, or starts with a digit, must be put in quotes. Text searches need extra care because some of the same characters also act as search operators.
Syntax
field = "value with reserved parts"
text ~ "value with \\- escaped character"
Arguments
| Argument | What it does | Optional |
|---|---|---|
Reserved characters | space, - ~ + . , ; ? | * / % ^ $ # @ [ ] | no |
Reserved words | after, and, as, avg, before, begin, by, commit, contains, count, distinct, else, empty, end, explain, from, having, if, in, inner, insert, into, is, isnull, left, like, limit, max, min, not, null, or, order, outer, right, select, sum, then, was, where, update | no |
Digits | A value that starts with a digit must be quoted, for example "3C". | no |
Works with
- Quotes: single (') or double (") quote marks both work.
- Text searches: quoting is not always enough when the character is one of the reserved characters for text searches. The documentation then asks for two backslashes before it.
- Applies to every field value, including inside IN lists.
Examples
title = "Order fulfillment flow" AND type = pageA title that starts with the reserved word order. Without the quotes the query fails.
Run on Confluence Cloud on .
title = "Template - Meeting notes"An exact title that contains a space and a hyphen. Both are reserved characters, so the whole value is quoted.
Run on Confluence Cloud on .
space = "3C"A space key that starts with a digit. Unquoted, 3C is not accepted.
Run on Confluence Cloud on .
label = "2026-q4"A label that starts with digits and contains a hyphen, the kind used for quarterly planning.
Run on Confluence Cloud on .
label in ("in", "or")Reserved words inside an IN list must each be quoted.
Run on Confluence Cloud on .
title ~ "release/checklist"A text search with a slash in it. The quotes keep the slash from being read as CQL syntax.
Run on Confluence Cloud on .
title ~ "Template \\- Meeting notes"A text search for the same title with the hyphen escaped by two backslashes, as the documentation asks for text fields.
Run on Confluence Cloud on .
Pitfalls
- A reserved word without quotes fails with a message that names the word: "'and' is a reserved keyword. You must surround 'and' in quotation marks to use it." The check applies to words inside an unquoted value too, so
title = Order fulfillment flowfails on "Order" (the check is not case sensitive). - Unquoted reserved characters usually fail with a vague parse error:
label = meeting-notes,title ~ v1.2andtitle ~ release/checklistall give "Could not parse cql". Some are split into separate clauses:space = 3Cgives "Unrecognised clause at : C" andtitle = Checkout service — design notesgives "Unrecognised clause at : servicedesignnotes". - Quoting makes the query valid but not always correct for a text search.
title ~ "Template - Meeting notes"runs and finds nothing, because the hyphen is also a search operator. Escape it with two backslashes, or drop the hyphen and search for "Meeting notes" (checked on Confluence Cloud, November 2026). - Quoting a plain English reserved word such as
title ~ "and"is accepted, but it is a text search for a very common word and can match pages that do not obviously contain it. Search for the words around it instead.
Questions and answers
Do I need quotes around a space key?
Only when the key itself is a problem, for example when it starts with a digit like 3C or is a reserved word. A plain key such as SD works without quotes, but quoting it is always safe.