Skip to content
TextArray
100% local

SQL formatter

Format SQL queries with each clause on its own line, consistent indentation and uppercase keywords.

Input
Output

SQL formatter

Paste any SQL query and get it back readable: SELECT, FROM, WHERE, JOIN, GROUP BY, HAVING, ORDER BY and the other major clauses each start their own line, AND and OR conditions continue indented beneath them, and every column in the select list can sit on its own line. Pick two spaces, four spaces or tabs for indentation, and choose whether keywords are uppercased — the classic SELECT/FROM/WHERE capitalization that makes structure visible at a glance.

The formatter is built on a real tokenizer, not a pile of find-and-replace rules. String literals such as 'it''s', quoted identifiers in every dialect style ("column", `column`, [column]) and both comment styles (-- line and /* block */) pass through byte for byte, so a keyword inside a string is never touched and a quote inside a comment never confuses it. Only whitespace and keyword case ever change — the query you get out means exactly what the query you pasted in meant.

Multiple statements separated by semicolons are recognized and formatted as separate blocks, which makes the tool practical for migration files and seed scripts, not just single queries. It is honest about its limits: deeply nested subqueries stay on their clause's line rather than being re-indented, which keeps the result predictable for the queries you actually debug day to day.

Everything runs locally in your browser — queries that contain table names, credentials or production data never leave your machine. Copy the result or download it as a .txt file when you are done.

FAQ

Will the formatter ever change what my query does?
No. Only whitespace and keyword case change. String literals, quoted identifiers, comments, numbers and operators pass through exactly as written, so the formatted query is semantically identical to the input.
How are complex nested subqueries handled?
This is a best-effort formatter. Top-level clauses get their own lines, but the content of parentheses — including subqueries — stays inline on its clause’s line. Keywords inside subqueries are still uppercased. For deeply nested queries the result is correct but not always perfectly indented.
Which keywords are uppercased?
Clause keywords (SELECT, FROM, WHERE, JOIN variants, GROUP BY, ORDER BY, INSERT INTO, UPDATE, DELETE FROM, CREATE TABLE and more), logical operators (AND, OR, NOT, IN, LIKE, BETWEEN) and common column types. Function names like count() are left alone, and nothing inside strings, quoted identifiers or comments is ever changed.
Can I format several statements at once?
Yes. Statements separated by top-level semicolons are formatted as separate blocks with a blank line between them. Semicolons inside string literals are ignored, as they should be.
Is my SQL uploaded anywhere?
No. The tool runs entirely in your browser and your queries never leave your device — safe even for SQL that references production schemas.