SQL Formatter
Paste a messy query and get clean, indented SQL with keywords uppercased and clauses on their own lines. Runs in your browser, nothing uploaded.
A cleaner query in one paste
This SQL formatter uppercases the keywords you know (SELECT, FROM, WHERE, the JOIN family, GROUP BY, ORDER BY, LIMIT and more), drops each major clause onto its own line, and indents AND and OR underneath so a long condition is easy to scan. Quoted strings are left untouched, so your literals stay exactly as written, and your comments are preserved too: both -- line comments and /* ... */ block comments are pulled out and put back on their own line, so nothing after a comment ever gets dropped. It is a fast convenience formatter rather than a full parser, which is all you usually need to make a query readable. Everything runs in your browser.
The query you will run again next week
Good queries get reused, then lost in a sea of terminal history. Relic keeps an end-to-end encrypted, searchable memory of everything you copy, on every device, for as long as you want. The formatter is free, and that query you just cleaned up is one search away the next time you need it.
Frequently asked questions
How do I format SQL?
Paste your query and the formatted version appears next to it: keywords uppercased, each major clause (SELECT, FROM, WHERE, the JOIN family, GROUP BY, ORDER BY, LIMIT) on its own line, and AND, OR, and ON indented under the clause they belong to. Copy the result in one click.
Will formatting change what my query does?
No. It only adds and removes whitespace and adjusts the case of keywords; it never rewrites the logic. Quoted string literals are left exactly as written, and both line comments (--) and block comments (/* ... */) are preserved, so the query runs the same as before.
Does it work with any SQL dialect?
Mostly. It is a fast convenience formatter, not a full parser, and it recognizes the common keywords shared across MySQL, PostgreSQL, SQL Server, SQLite, and others. Very dialect-specific or deeply nested syntax may not indent perfectly, but the output stays valid and far more readable than a one-line query.
Why does the formatter uppercase my keywords?
Uppercasing keywords like SELECT and WHERE is a long-standing SQL convention that makes the structure of a query jump out from the table and column names. Your identifiers and string literals keep their original case.
Is my query uploaded when I format it?
No. Formatting runs entirely in your browser, so queries containing real table names or embedded values never leave your machine.