SQL Formatter
Paste a messy one-line query and get clean, readable SQL with every major clause on its own line. Runs entirely in your browser.
Paste a messy one-line query and get clean, readable SQL with every major clause on its own line. Runs entirely in your browser.
Turn a cramped, single-line query into formatted SQL in three steps.
Drop a SELECT, INSERT, UPDATE, or DELETE statement into the box. Multi-clause queries with JOINs and WHERE conditions are exactly what this tool is built for.
Choose UPPERCASE, lowercase, or preserve for keywords, and a 2-space, 4-space, or tab indent for the SELECT column list and AND/OR continuations.
Read the result, copy it back into your editor, or download it as a .sql file. Same input always gives the same output.
A focused beautifier that respects the parts of your query that must not change.
String literals, double-quoted identifiers, and backtick-quoted names are preserved character-for-character - keywords inside 'from where' or "order by" are never reformatted.
SELECT, FROM, the full JOIN family, ON, WHERE, GROUP BY, HAVING, ORDER BY, LIMIT, INSERT INTO, UPDATE, DELETE, VALUES, and SET each land on their own line, with AND/OR continuations indented underneath.
Line comments (--) and block comments (/* ... */) are kept verbatim and travel with the code they annotate instead of being stripped or mangled.
The formatter is pure client-side JavaScript with no network calls. Paste production SQL, schema names, and table structures with no upload.