SQL and GraphQL Formatter

Paste a messy SQL or GraphQL query and pretty-print it with clean indentation.

Ad placeholder (leaderboard)
Enjoying the tools? Go Pro for £4.99 (one-time) and remove all ads — forever, on this device. Remove ads — £4.99

A fast, private SQL and GraphQL formatter that turns a cramped, one-line query into clean, readable, properly indented code. Paste anything — a query copied out of a log, a string ripped from application code, or a hand-written statement that has drifted out of shape — and the tool rebuilds it with consistent line breaks and indentation so you can actually read it. It is built for developers, data analysts, and anyone who reviews queries during code review or debugging and wants a tidy result without pasting confidential SQL into a random website.

Two engines live behind a single toggle. The SQL mode understands the reserved words shared by PostgreSQL, MySQL, SQLite, SQL Server and ANSI SQL, so it knows to start a fresh line at SELECT, FROM, WHERE, each JOIN, GROUP BY, HAVING and ORDER BY, to indent AND / OR conditions, and to break long column and value lists one item per line. The GraphQL mode works structurally on braces, arguments and directives, so queries, mutations, subscriptions, fragments and schema definition language all indent correctly even though they share no grammar with SQL.

How it works

When you type or paste, the input is run through a hand-written tokeniser. For SQL that means splitting the text into keywords, identifiers, string literals, numbers, comments and operators — while carefully preserving the contents of quoted strings and -- or block comments so nothing inside them is reformatted. The formatter then walks the token stream, opening a new line before each top-level clause, increasing the indent inside parentheses and sub-queries, and applying your chosen keyword casing. GraphQL is handled by a brace-and-paren-aware pass that increases depth on {, keeps argument lists like (first: 10) on the same line, normalises : spacing, and drops the insignificant commas the GraphQL spec allows. Because the whole pipeline is plain JavaScript running in your tab, formatting is instant and completely offline — ideal for queries that touch private data. You can copy the result, download it as a .sql or .graphql file, or hit Minify to collapse it back to a single line.

Example

Paste this unreadable one-liner into SQL mode:

select u.id, u.name, count(o.id) as orders from users u left join orders o on o.user_id = u.id where u.status in ('active','trial') group by u.id, u.name having count(o.id) > 3 order by orders desc;

and it becomes:

StageResult
Inputone cramped line, ~210 characters
OutputSELECT / FROM / LEFT JOIN / WHERE / GROUP BY / HAVING / ORDER BY each on their own line
Columnsthe three selected columns broken one per line and indented

Switch to GraphQL mode and a tangled query GetUser($id: ID!) { user(id: $id) { id name orders(first: 10) { edges { node { id total } } } } } expands into a neatly nested tree with each selection on its own indented line. Every character is processed locally — no query, schema, or credential ever leaves your browser.

Ad placeholder (rectangle)