Clause per line
SELECT, FROM, joins, WHERE, GROUP BY, HAVING, ORDER BY and LIMIT each start a line, with AND and OR conditions indented under WHERE.
Lay out a long SQL query with each clause on its own line, keywords in capitals and subqueries indented. Strings and comments are never changed.
Paste one or more SQL statements
Choose capitals or the case you wrote
Copy or download the formatted SQL
A query copied out of a log, an ORM or a colleague’s message usually arrives as one long line. This lays it out the way people write SQL by hand, so you can see what it selects, what it joins and what it filters.
Each main clause starts a new line: SELECT, FROM, every kind of JOIN, WHERE, GROUP BY, HAVING, ORDER BY, LIMIT, and the parts of INSERT, UPDATE and DELETE. The selected columns sit one per line under SELECT. Conditions joined by AND or OR each get their own line, indented under WHERE, except the AND inside BETWEEN, which belongs to its range.
A parenthesis can hold two different things, and they are laid out differently. A subquery, one that starts with SELECT or WITH, is indented one level past the line that opens it and closed on its own line, so a nested query reads like a query. Function arguments, IN lists and column lists stay on the line where they are, with their commas inline, because COUNT(o.id) split over three lines is harder to read, not easier.
Strings in single quotes, names in double quotes, backticks or square brackets, and comments are recognised before anything else and passed through exactly. A column called "order" or a value of 'select * from' stays as written, and keywords are capitalised only where they are keywords. Choose As written to keep your own case everywhere.
The formatter reads the text and does not run it, so it works for any common dialect and needs no connection to a database. It does not check that the query is valid. For quick checks against data, Query a CSV with SQL runs SQL on a spreadsheet in your browser, and the CSS minifier does for stylesheets what this does for queries.
Queries often contain table names, customer IDs and the shape of a schema that is not public. Nothing pasted here leaves your device.
SELECT, FROM, joins, WHERE, GROUP BY, HAVING, ORDER BY and LIMIT each start a line, with AND and OR conditions indented under WHERE.
A query inside parentheses is laid out one level in, under the line that opens it, while function calls and IN lists stay on one line.
Quoted values, quoted names and comments pass through exactly as written, including any keywords inside them.
Nothing uploaded: open the Network panel while it runs and check.
No daily limits or watermarks: free batches take up to 20 images.
Works offline: once the page has loaded, on any current browser.
Any that use the common SQL clauses, including PostgreSQL, MySQL, SQLite, SQL Server and Oracle. It reformats text rather than running the query, so it does not need to know which database it is.
Only its layout and the case of keywords. Values in quotes, quoted names, backtick and bracket names and comments are left exactly as written, and nothing is added or removed.
No. It formats what it is given. A query with a typo comes out laid out with the typo in place, which often makes the typo easier to see.
Yes. Statements ending in a semicolon are laid out one after another with a blank line between them.