Updated · Built and checked by the PlinzoTools team, formulas tested against published sources
Beautify a SQL statement -- uppercase keywords and break clauses onto new lines.
SELECT id, name
FROM users
WHERE age > 18
AND active = 1This tool beautifies a SQL statement for readability: it uppercases major keywords (SELECT, FROM, WHERE, JOIN, etc.) and breaks each major clause onto its own line. It's a keyword-based beautifier, not a full SQL parser -- it works on the statement's text structure rather than deeply understanding SQL syntax.
Paste a SQL statement (even one written on a single line). The formatted version appears instantly.
Major clause keywords (SELECT, FROM, WHERE, JOIN variants, GROUP BY, ORDER BY, HAVING, LIMIT, AND, OR, and DML keywords like INSERT/UPDATE/DELETE) are uppercased and each is preceded by a line break, with AND/OR additionally indented for readability.
select id, name from users where age > 18 and active = 1 becomes:
SELECT id, name
FROM users
WHERE age > 18
AND active = 1
For formatting JSON output from a database query instead, see the JSON to CSV Converter or general XML Formatter depending on your data's shape.
The tool first collapses every run of whitespace, including existing line breaks, into a single space, so previously formatted SQL is flattened before being reformatted. It then uppercases the recognized keywords: SELECT, FROM, WHERE, GROUP BY, ORDER BY, HAVING, LIMIT, the JOIN forms, INSERT INTO, VALUES, UPDATE, SET, DELETE FROM, AND and OR. New lines are inserted before SELECT, FROM, WHERE, GROUP BY, ORDER BY, HAVING, LIMIT, the JOIN forms, VALUES, SET, AND and OR, and AND and OR receive a two-space indent. INSERT INTO, UPDATE and DELETE FROM are uppercased but do not start a new line, so they stay on the same line as the preceding text. Other words, such as ON, IN, LIKE, AS, CASE, DISTINCT or function names, are not touched and keep whatever case you typed.
Take the hypothetical statement: select o.id, c.name from orders o inner join customers c on o.cid = c.id where o.total > 100 order by o.id. The result places SELECT on the first line with its column list, then FROM orders o, then INNER JOIN customers c on o.cid = c.id, then WHERE, then ORDER BY, each on its own line. Note that the word on stays in lower case because it is not in the keyword list, and the join condition remains on the same line as the JOIN.
Because the tool works on text patterns and not on a real parse, it cannot tell a keyword from a word inside a quoted string. A literal such as 'this and that' contains the word and, which would be uppercased and given a line break, changing the string's contents. The same happens with a column or alias that happens to be named like a keyword. Whitespace is also collapsed inside quotes, so a string with two spaces in a row becomes one. This makes the output unsafe to run against a database when your statement includes string literals containing keywords or repeated spaces. Use it to read and review queries, and check the literals afterward, or take the formatted layout and re-paste the original literals by hand.
Format a query before reading it in a code review so that each clause is visible and the filter conditions can be scanned one per line. When a query returns wrong data, look at the WHERE section first for mixed AND and OR conditions and check whether parentheses are needed, since the formatter does not add them. For performance advice or correctness checks, use your database's own explain or validation features and consult your database administrator, because a beautifier cannot judge either.
No -- it's a text-based beautifier, not a SQL parser, so it reformats keywords it recognizes without checking overall query validity.
It formats the common keywords shared across most SQL dialects -- dialect-specific syntax (like MySQL's backtick identifiers) passes through unchanged rather than being specially formatted.
No -- only whitespace, line breaks, and keyword casing are changed; the query's logic and structure remain identical.
It matches keywords by text pattern and does not recognize quotes, so keywords like and inside a string literal are uppercased and split onto a new line. Whitespace inside strings is also collapsed.
No. Only AND and OR lines receive an indent. Subqueries and parenthesized groups stay flat.
Only the listed clause and DML keywords are changed. ON, IN, AS, LIKE and function names keep the case you typed.
Line breaks are collapsed, so a comment starting with two hyphens can absorb the code that follows it. Remove comments before formatting.
Reference: MDN Web Docs