Kitefold
Guides

Confluence clean-up searches with CQL, and what CQL can’t find

CQL (Confluence Query Language) is the search language behind Confluence. It's good at clean-up jobs that depend on dates, types, macros, labels or where a page sits: pages nobody has edited in a year, every PDF in a space, every page that uses a macro. It can't search links at all, so broken links, orphan pages and unused attachments are beyond it. Below are searches you can copy, and what to use for the rest.

Where to run a CQL search

Confluence Cloud has no CQL box in its search screen. Two ways that work:

  • In the address bar: type your site's address followed by /wiki/search?cql= and the search, for example https://your-site.atlassian.net/wiki/search?cql=type = page AND space = DOCS. The browser fills in the spaces and quotes for you, and the results open in Confluence's normal search screen.
  • As data: /wiki/rest/api/search?cql= instead returns the results as JSON, with the total in totalSize. Handy for a quick count.

The search screen lists the results but doesn't show how many there are. Either way, a search only returns what you're allowed to see. Replace DOCS with your space key and the numbers with your own.

Put values with a hyphen in quotes, such as "excerpt-include". Without the quotes Confluence can't read the search, and the search screen only says it couldn't find anything, as if there were no results.

Searches that work

Pages nobody has edited in a year

type = page AND lastmodified < startOfDay("-12M") ORDER BY lastmodified ASC

Oldest first. Change -12M to -6M or -24M for six months or two years, and add AND space = DOCS for one space. “Edited” means the page itself; comments and views don't count.

Your own pages that have gone quiet

type = page AND creator = currentUser() AND lastmodified < startOfDay("-6M")

A good first list to tidy, because you know whether they're still needed.

Files of one type

type = attachment AND fileExtension in ("pdf", "zip") AND space = DOCS

Lists attached files by extension. CQL has no size field, so it can't sort them by size; for that, see unused attachments.

Pages that use a macro

type = page AND macro in ("include", "excerpt-include")

Pages that copy in content from other pages, which breaks when the source page goes. Use the macro's name, for example jira, attachments or children.

Everything under one page

ancestor = 123456 AND lastmodified < startOfDay("-12M")

Every page below a page, at any depth, that nobody has edited in a year. The number is the page's id: it's in the page's address, after /pages/. A space's homepage shows /overview instead, so start from a page below it, or add AND space = DOCS to search the whole space.

Pages labelled for clean-up

label in ("obsolete", "archive-me") ORDER BY lastmodified ASC

If your team labels pages to remove, this gathers them from every space.

What CQL can't find

CQL's fields cover a page's text, title, labels, dates, people, space, type, macros and position in the page tree. There's no field for links, and no way to ask for pages without a parent. So these clean-up jobs need something else:

  • Broken links. CQL can't search a page's links, so it can't tell you which ones lead nowhere. Confluence lists links to missing pages one space at a time: see how to find broken links.
  • Which pages link to a page. No link field means no “linked from” search. Each page's Details panel shows its incoming links: see which pages link to a page.
  • Orphan pages. Pages nothing links to can't be found without searching links, and parent only finds the children of a page you name. See orphan pages.
  • Unused attachments. CQL finds files, but not whether any page shows or links to them, and not their size. See unused attachments.
  • Links to your old server. Text search looks at the words on a page, not where its links point. On our test site, searching for the old address found no pages at all, although 119 links still pointed to it; searching for part of the address found some of those pages but not all. See old links after a move to Cloud.

The link jobs, across every space, with Link Health & Cleanup

Link Health & Cleanup keeps an index of every link on your site, so it can list what CQL can't: broken links, links to your old server, orphan pages and unused attachments, largest first, across every space. Its Stale pages tab runs the same kind of date search as the first one above, as you, for the age you pick. Every list only shows pages you can open, and you can archive pages or move files to the trash from the lists (both can be undone).

Disclosure: Kitefold makes Link Health & Cleanup, so we're not neutral. The searches above are free and may be all you need.

CQL from Atlassian's developer documentation, and each search tried on our test site, November 2026. Confluence changes often; if something here no longer matches what you see, email support@kitefold.app and we'll update it.