About this tool
SQL is written by generators, ORMs and hurried humans, and all three produce the same unreadable slab. Formatting a query is not vanity: the clause structure IS the query's logic — what is selected, from where, filtered how, joined to what — and it only becomes reviewable when each clause stands on its own line. This formatter tokenises carefully (string literals are never touched), uppercases the keywords, and lays the clauses out in reading order.
Scope, honestly: it formats the mainstream of SELECT, INSERT, UPDATE and DELETE statements, including joins, grouping, ordering, limits and subqueries at the top level of indentation. Exotic vendor syntax and deeply nested expressions may come out less sculpted than a dedicated IDE would manage — but the output is always valid, because formatting here never alters a token, only the whitespace between them and the case of keywords.
How to use it
- Paste the query.
- Press Format SQL.
- Read it top to bottom — then copy it back wherever it needs to live.
Good to know
- Format before you debug: half of all 'wrong results' bugs are a WHERE clause quietly applying to the wrong join, visible at a glance once formatted.
- Keep the formatted version in your ticket or doc; the next person inherits the readability.
- String contents keep their exact case and spacing — only keywords outside quotes are capitalised.
Frequently asked questions
Will it change my query's meaning?
No. Tokens are preserved; only whitespace and keyword case change.
Which databases' SQL does it suit?
The clause layout is standard SQL — MySQL, PostgreSQL, SQLite and SQL Server queries all format sensibly.
Is my query uploaded?
No — formatting runs in your browser, so proprietary schemas stay private.
More Developer tools
JSON Formatter & Validator
Pretty-print messy JSON, minify it back, and get a precise error location when it will not parse.
JSON to CSV
Turn a JSON array of objects into a clean spreadsheet-ready CSV, columns and escaping handled.
CSV to JSON
Convert spreadsheet CSV into a JSON array — quoted fields, embedded commas and all.
XML Formatter
Indent and validate XML — sitemaps, feeds, config files — with errors pointed at the guilty tag.
JS / CSS / HTML Beautifier
Untangle minified or messy code into readable, consistently indented JavaScript, CSS or HTML.
JS / CSS Minifier
Strip comments and needless whitespace from JavaScript and CSS — smaller files, same behaviour.
Making videos too? Try our YouTube SEO Checker, or browse the full Toolkit and the free YouTube tools.