Going Stellar

Home/CQL reference

CQL keyword

NOT keyword in CQL (Confluence): syntax and examples

NOT negates a clause that comes after it, or a whole group in parentheses. Use it for conditions that have no negative operator, or to flip an OR group in one step instead of rewriting each clause.

Syntax

clause1 AND NOT clause2
clause1 and not (clause2 or clause3)

Arguments

ArgumentWhat it doesOptional
clauseA CQL clause, or several clauses in parentheses.yes

Works with

  • Operators: negates a clause with any operator, including ~ and IN.
  • Functions: any function inside the negated clause.
  • Not with: the start of a query, and a clause with no AND or OR before it.

Examples

type = page and not space = SD

Finds pages that live outside one space.

Run on Confluence Cloud on .

type = page and not title ~ "template"

Removes template pages from a page list without a !~ clause.

Run on Confluence Cloud on .

type = page and space = SD and not (title ~ "template" or title ~ "policy")

Excludes two kinds of page with one negation by grouping them.

Run on Confluence Cloud on .

space = SD and not type = attachment

Keeps everything in a space except uploaded files.

Run on Confluence Cloud on .

label = cql and not space = SD

The documentation example, with a space key that exists. Finds labelled pages that are not in the space.

Run on Confluence Cloud on .

Pitfalls

  • NOT cannot start a query. not space = SD fails with "Could not parse cql". Put a positive clause first and join with AND, as in type = page and not space = SD (checked on Confluence Cloud, November 2026).
  • NOT still needs a joiner. type = page and space = SD not title ~ "template" fails with the same parse error. Write and not.
  • Case does not matter. not, NOT and Not all run (checked on Confluence Cloud, November 2026), so the lowercase form in the Atlassian example is valid.
  • For simple cases the negative operators read better: !=, !~ and NOT IN need no extra keyword.

Sources

  1. CQL keywords (Atlassian Developer, Confluence Cloud)

Markdown version · All CQL pages