About SQL Formatter
The SQL Formatter is a free sql formatter that turns cramped, single-line queries into readable SQL: keywords are uppercased and major clauses — SELECT, FROM, WHERE, JOINs, GROUP BY, ORDER BY — each start on their own line with sensible indentation. It's the fastest way to pretty print sql you've copied from a log file, an ORM's generated output, or a colleague's Slack message. It also helps when learning SQL — seeing a query broken into its component clauses on separate lines makes the logical structure (what's being selected, from where, filtered by what) far easier to follow than a dense single line.
Long queries — the kind an ORM like Prisma, Sequelize or Hibernate generates, or a query pulled from slow-query logs — are nearly impossible to review as one continuous line. Running them through the sql beautifier turns that wall of text into a query you can actually scan for the right JOIN condition, spot a missing WHERE clause, or diff against a previous version in a code review. It's equally handy for cleaning up your own SQL before committing it to a migration file or a saved query. It's also useful before a code review: a formatted query is easier for a reviewer to scan for a missing index-friendly WHERE clause, an accidental cross join, or a SELECT * that should really list specific columns.
The formatter recognizes standard SQL keywords shared across PostgreSQL, MySQL, SQL Server, SQLite and most other dialects, uppercasing them consistently while leaving identifiers, table names and string literals exactly as written — so the query means precisely the same thing before and after. Multiple statements separated by semicolons are each formatted in turn, and comments in the original query — whether inline -- comments or /* block comments */ — are preserved rather than stripped, since silently removing them could delete context a teammate left for a reason.
Formatting runs entirely in your browser, so production queries, table names and schema details containing business logic never leave your machine — useful when the query itself is sensitive.
How to Use the SQL Formatter
- Paste your SQL query into the input pane.
- The formatted query appears instantly with uppercase keywords and one clause per line.
- Copy the result back into your code or editor.
Features
- Uppercases SQL keywords automatically
- New line per major clause, indented JOINs and conditions
- Preserves string literals exactly as written
- Handles multiple statements separated by semicolons
Examples
Formatting a query copied from application logs
Input
select id, name, email from users where active = true and created_at > '2024-01-01' order by created_at desc;
Output
SELECT id, name, email FROM users WHERE active = true AND created_at > '2024-01-01' ORDER BY created_at DESC;
Formatting a query with a JOIN
Input
select o.id, u.name from orders o join users u on o.user_id = u.id where o.status = 'paid';
Output
SELECT o.id, u.name FROM orders o JOIN users u ON o.user_id = u.id WHERE o.status = 'paid';
Frequently Asked Questions
Which SQL dialects are supported?
The formatter works on standard SQL keywords shared by PostgreSQL, MySQL, SQL Server, SQLite and most other dialects. Dialect-specific syntax passes through unchanged.
Will formatting change what my query does?
No. Only whitespace and keyword casing change; identifiers and string literals are preserved exactly, so the query executes identically.
Can I format multiple SQL statements at once?
Yes — paste several statements separated by semicolons and each one is formatted in turn, in the order it appears, so you can clean up an entire migration file in one pass.
Is the SQL Formatter free?
Yes, the SQL Formatter is completely free with no usage limits. No signup, no account and no installation required.
Is my data safe?
Yes. All processing happens locally in your browser using JavaScript — nothing you type is uploaded or stored on our servers.
Related Tools
JSON Formatter
Format, validate and beautify JSON online. Free JSON formatter with indentation options and key sorting — runs entirely in your browser.
CSS Minifier & Beautifier
Minify CSS to shrink file size or beautify it into readable, indented code. Free online CSS formatter — instant and client-side.
CSV to JSON
Convert CSV data to JSON online with header detection, custom delimiters and quoted-field support. Fast, free and private.
YAML Formatter
Format and validate YAML, or convert between YAML and JSON. Free online YAML formatter for configs, pipelines and Kubernetes files.
JavaScript Beautifier / Minifier
Beautify minified JavaScript into readable code, or minify it to shrink file size. Free online JS formatter — runs entirely in your browser.
String Escape / Unescape
Escape or unescape strings for JavaScript, JSON, HTML, SQL or CSV contexts. Free online string escaping tool, runs in your browser.
JSON to CSV
Convert a JSON array to CSV with automatic column detection and proper quoting. Free online JSON to CSV converter.