A SQL scraped out of a log arrives as one crushed line, and five JOINs in tell you nothing about who connects to whom. Paste it here for one-click indentation: every JOIN of a multi-table query gets its own line, subqueries shift right as a block, CASE WHEN branches align, UNION sections split with blank lines - keyword uppercase optional, and not one character inside quoted strings gets touched.
SQL you paste is rearranged in this page's memory only - no database connection, no execution, no uploads, works offline. Interface options like indent and comma style live in this device's browser and are lost when you switch devices or clear site data. To remove them, use "Clear my data" in the footer.
SELECT columns one per line, clauses on their own lines: FROM / WHERE / GROUP BY / ORDER BY / LIMIT each start a line; AND/OR conditions inside WHERE break one per line. In multi-table queries every JOIN gets its own line with the ON condition following.
Subqueries indent as a whole: the subquery inside WHERE id IN (SELECT ...) wraps and shifts right one level; each WHEN/THEN of a CASE WHEN takes its own line, END closes. UNION / UNION ALL sections separate with a blank line.
String literals are never split: content inside single quotes, double quotes, backticks or brackets (commas, newlines, keywords included) is kept whole - 'hello, world' is not two columns, and the column name "select" never gets uppercased.
The classic case is slow-query triage: the SQL behind an EXPLAIN arrives as one line; paste it in and the tree-shaped indentation shows which table JOINs which and which condition hangs on which field at a glance. Formatting your SQL before code review is also basic team courtesy.
The reverse direction helps too: compress a typeset query back to one line for log-system searches - two buttons, done.
| Input | Any SQL text (SELECT/INSERT/UPDATE/DELETE/CREATE TABLE/ALTER/DROP; multiple statements separated by semicolons); ≤1MB |
|---|---|
| Output | Formatted (indent 2/4; JOIN/subquery/CASE WHEN/UNION on their own lines) or minified (one line); keyword uppercase optional |
| Key parameters | Indent 2 by default; comma style trailing by default; uppercase off by default; ?indent=4&comma=leading&upper=1 deep-links |
| Processing | Browser-local pure text processing - no database, no execution, no uploads; interface options in localStorage |
| Limits | 1MB per run (tens of thousands of SQL lines in milliseconds) |
| Known limits | Typesetting only, no syntax validation (use the site's SQL validator for that); stored-procedure bodies and window-function OVER/PARTITION BY kept as-is without special indentation; SQL inside comments is not parsed |
No. The tool only adjusts whitespace and line breaks - it never adds, removes or modifies a single meaningful character: string literals (content inside single or double quotes, backticks) are preserved verbatim, comma style only moves whitespace and newlines around the comma, and keyword casing does not change SQL semantics (SQL keywords are case-insensitive). Formatting formatted output again yields identical results.
Never. String literals and quoted identifiers ("select", 'hello, world', `order`) are recognized as single whole tokens - keywords, commas and newlines inside them stay untouched, and keyword uppercasing only applies to real keywords outside quotes. Escaped forms like 'It''s fine' are recognized correctly too.
Trailing commas (default): the comma stays at the end of the current line, like name, then age on the next. Leading commas: the comma starts the next line, like name then , age - handier when you comment rows out. Rare in SQL but some people swear by it. One click switches between the two styles in the options area.
The generic SQL skeleton: SELECT/INSERT/UPDATE/DELETE/CREATE TABLE/ALTER/DROP, the JOIN family (INNER/LEFT/RIGHT/FULL/CROSS), UNION/UNION ALL, CASE WHEN, subqueries and CTEs (WITH). MySQL backticks, PostgreSQL double-quoted identifiers and :: casts, SQLite bracket identifiers are all preserved as literals. Stored procedures and window-function OVER clauses are formatted as-is without special indentation.
No. This page is a pure text processor - it connects to no database, executes nothing, only rearranges characters, and works offline. Interface options live in this browser's localStorage; Clear my data in the footer removes them.
No, and it does not pretend to. This page typesets only and judges nothing about syntax (an unclosed quote gets an error message, but that is all). To check CREATE TABLE structure, constraints and INSERT column counts, use the site's SQL validator - its errors come with line and column numbers.