🗃 SQL Formatter & Beautifier
Format, beautify, and minify SQL queries with syntax highlighting. Queries are handled by the page itself, not by a server.
Last updated: November 8, 2026 · By the BoltQuickTools team
Make a one-line query readable
Queries copied out of application logs or ORM debug output usually arrive as one long line. Putting each clause on its own line makes joins and filters easy to review. Use the formatter for reading and diffing, and read the warnings below before running its output against a real database.
How to format
- Paste into Input SQL.
- Choose Indent (2 Spaces, 4 Spaces or Tab) and Keywords (UPPERCASE, lowercase or Preserve).
- Press Format / Beautify, or Minify to squeeze it onto one line. Copy Output takes the plain text and Clear resets.
Before and after
Input, with 4 Spaces and UPPERCASE:
select u.id, u.name, o.total from users u join orders o on u.id = o.user_id where o.total > 100 and u.active = 1 order by o.total desc
Format / Beautify gives the following, with the note "134 chars in, 150 chars out, 9 lines":
SELECT u.id,
u.name,
o.total
FROM users u
JOIN orders o
ON u.id = o.user_id
WHERE o.total > 100
AND u.active = 1
ORDER BY o.total DESC
Minify of the same input gives:
SELECT u.id,u.name,o.total FROM users u JOIN orders o ON u.id = o.user_id WHERE o.total > 100 AND u.active = 1 order by o.total DESC
The lowercase order by is real output: minify uppercases keywords from a list that does not include ORDER or GROUP.
When formatting changes the meaning
This is a tokenizer with spacing rules, not a SQL parser, and it has no dialect setting. These inputs produce broken or altered SQL:
| Input | Format / Beautify output | Problem |
|---|---|---|
select a, -- the first column with b from t on the next line | -- the first column b | The next code joins the comment line, so column b is commented out |
a::int | a : : int | PostgreSQL cast is split |
b || c | b | | c | Concatenation is split |
data->>'name' | data - >> 'name' | JSON operator is split |
[Order Details] | [ Order Details ] | SQL Server names get extra spaces |
"a""b" | "a" "b" | Escaped quote in an identifier is lost |
'it\'s' | 'it\' s ' | Backslash escapes are not recognised |
PostgreSQL dollar-quoted bodies are also read as ordinary SQL rather than as strings. Minify avoids most of the spacing problems: a::int,b||c stays intact there, and it removes comments completely.
Cosmetic quirks
- Every comma starts a new line, so
coalesce(a, b)andin (1, 2, 3)are broken across lines. - Keyword case applies wherever the word appears, so a column named
key,countorleftgets uppercased. - Only keywords and COUNT, SUM, AVG, MIN and MAX change case. Other function names are left as written.
COUNT(*)becomesCOUNT(* ), and-1becomes- 1. These are harmless.- Preserve keeps your case except for multi-word keywords, which always come out in capitals, such as
GROUP BYandORDER BY.
Validation, privacy and comparing output
Will it tell me if my SQL is wrong?
No, it does not validate anything. selct frm wher (( is accepted without complaint and comes back as formatted text. The SQL cheatsheet is there for checking syntax.
Is my query sent to a server?
The code that formats it runs in the page and makes no network request.
How can I spot what a formatter changed?
Compare the original and the output in the text diff tool. Whitespace differences are expected, and any changed word or operator deserves a second look.