SQL Formatter
Format SQL queries with consistent indentation and keyword casing. Supports MySQL, PostgreSQL, and standard SQL.
How to use SQL Formatter
- 1Paste SQL
Paste the query you want to format.
- 2Click Format
Indented, uppercased-keyword SQL appears in the output pane.
About SQL Formatter
SQL queries — especially the multi-join, subquery-heavy ones generated by ORMs or written by junior teammates — can easily span several hundred characters on a single line with wildly inconsistent capitalization. A formatter rewrites the query with consistent indentation, line breaks at major clauses (SELECT, FROM, WHERE, JOIN), and a chosen keyword case.
Readable SQL is debuggable SQL: you can spot a missing JOIN condition, an accidental Cartesian product, or a WHERE clause that filters the wrong table much faster when the structure is visible. Utilify formats Standard SQL, MySQL, PostgreSQL, SQLite, MS SQL, and BigQuery — everything happens in your browser, so even queries that reference production schema details stay private.
The convention of uppercasing keywords (SELECT, FROM, WHERE) while leaving identifiers (table and column names) in their natural case is the most widely used SQL style. It creates an instant visual separation between the language and your data: your eye learns to skim the uppercase words as structure and the lowercase words as content. If your team prefers all-lowercase keywords, the case toggle switches the whole query in one click.
Formatting is purely cosmetic — it never changes what the query does. The tool reflows whitespace and casing but leaves the logic, table names, literals, and clause order untouched, so the formatted query returns exactly the same result set as the original. That makes it safe to run on anything: a one-liner copied from a log, a generated migration, or a 200-line analytics report.
A readable layout also pays off in code review and version control. When every query in your migrations and seed files follows the same indentation and casing, diffs highlight real logic changes instead of drowning them in reformatting noise — and a reviewer can scan a complex join at a glance instead of mentally re-indenting it first.
When to use SQL Formatter
- Reviewing ORM output
ORMs like Prisma and Hibernate produce minified, hard-to-read SQL. Format before reviewing.
- PR code review
Reformat raw SQL in migrations or seed files before committing for cleaner diffs.
- Learning SQL
Format example queries from tutorials to see clause structure clearly.
Examples
select u.id, u.name, count(o.id) as orders from users u left join orders o on o.user_id = u.id where u.active = 1 group by u.id, u.name order by orders desc limit 10
SELECT u.id, u.name, COUNT(o.id) AS orders FROM users u LEFT JOIN orders o ON o.user_id = u.id WHERE u.active = 1 GROUP BY u.id, u.name ORDER BY orders desc LIMIT 10
Frequently asked questions
Which SQL dialects are supported?+
Standard SQL, MySQL, PostgreSQL, SQLite, MS SQL, and BigQuery.
Can I lowercase keywords?+
Yes — use the case toggle to switch all keywords between upper and lower case in one click.
Does formatting change what my query returns?+
No. Formatting only reflows whitespace and keyword casing. The logic, table names, literals, and clause order are untouched, so the result set is identical.
Is my query sent to a server?+
No. Formatting runs entirely in your browser, so queries that reference production schema or sensitive table names stay on your device.
Why uppercase keywords?+
Uppercasing keywords while leaving identifiers in their natural case visually separates the SQL language from your data, making complex queries far easier to scan. It is a convention, not a requirement — toggle it off if you prefer lowercase.
Related tools
Format, beautify, and validate JSON online. Free, fast, runs entirely in your browser.
Validate JSON syntax online with clear error messages and line numbers. Free and private.
Encode and decode Base64 strings online. UTF-8 safe, browser-only — your data never leaves your device.
From the blog
A JWS (signed JWT) has 3 parts; a JWE (encrypted JWT) has 5. Learn what each JOSE acronym means, when a token is signed vs encrypted, and which you need.
RFC 7519 defines 7 registered JWT claims: iss, sub, aud, exp, nbf, iat, jti. Learn what each means, how to validate it, and the checks that stop attacks.