SQL Formatter Online – Format SQL Free
Readable SQL, exact errors.
At a glance
- Input:
- SQL
- Processing:
- Runs locally in your browser
- Privacy:
- Nothing you type is sent to a server
Last updated: 2026-11-13
Common use cases
- Untangling a minified query or migration into readable SQL
- Checking a pasted query for unclosed quotes or a JOIN without ON before running it
- Shrinking a query before pasting it into a report or chat
- Switching a query between dialects and catching quoting that does not travel
About this tool
A fast, private SQL formatter with 8 dialects, keyword case and indent control, minify mode and error messages that point at the exact offending character — strings, comments and parameters are never touched.
How to use it
- Paste SQL into the editor.
- Pick a dialect, then Format or Minify — and the keyword case and indent for Format (⌘/Ctrl+Enter works too).
- Read the result, or the exact line and column of the first error.
- Copy the result or download as .sql.
Worked examples
Input: select id,name from users where age>18 order by name;
Output: SELECT id, name FROM users WHERE age > 18 ORDER BY name;
The headline example: 4 lines at 2-space indent — verified.
Input: select 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.name order by orders desc;
Output: SELECT 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.name ORDER BY orders DESC;
JOINs, aggregates and GROUP BY line up at the clause indent — verified.
Input: SELECT id, name FROM users WHERE age > 18 ORDER BY name;
Output: SELECT id,name FROM users WHERE age>18 ORDER BY name;
Minify mode: the same query squeezed to one line — verified.
Practical tips
- Use Ctrl/⌘+Enter to re-run after each fix — the shortcut keeps hands on the keyboard.
- Format first, minify last: debug the readable version, ship the small one.
- Pick the dialect before formatting — backticks that are fine in MySQL are an error in PostgreSQL, and the tool tells you so.
Common mistakes
- Pasting SQL with an unclosed quote — the error names the exact line and column of the opening quote.
- Expecting formatting to fix broken SQL: it only re-indents valid queries, it never repairs them.
- Formatting a query written for another dialect without switching the dialect first — the dialect errors are the point, not a bug.
How this compares
Most SQL formatters in the field are server-side paste bins that upload your queries, or thin wrappers that re-indent without checking anything. This one formats locally with no upload, validates structure with exact line numbers — unclosed quotes, unbalanced parentheses, JOIN without ON — and enforces dialect quoting rules. The tradeoff: no query execution and no schema-aware checks — the formatter never sees your database, so it cannot tell you a table does not exist.
Good to know
- Formatting is not validation — a query against a table that does not exist formats fine; the tool only reports structural problems.
- String literals, quoted identifiers, comments and parameters are copied verbatim, so their inner spacing is yours, not the formatter's.
- The 1,000,000-character cap keeps huge scripts responsive; split larger files before pasting.
Frequently asked questions
Does formatting send my SQL anywhere?
No. Formatting runs entirely in your browser — safe even for queries with internal table names, hostnames or tokens in comments you'd rather not leak.
What do the 8 dialects change?
Which identifier quoting, comment styles and parameter styles are accepted: backticks in MySQL and BigQuery, brackets in T-SQL and SQLite, dollar-quoting and $1 parameters in PostgreSQL, Redshift and Snowflake, # comments in MySQL and BigQuery. A construct from the wrong dialect is reported as an error with its line and column instead of being silently reformatted.
What counts as an error?
Unclosed strings, comments, quoted identifiers and parentheses, plus a JOIN without ON or USING — each reported with the exact line and column. Formatting is not validation: a query against a table that does not exist formats fine.
How much smaller does minify make SQL?
The sample on this page is 140 characters pasted, 145 formatted and 139 minified — 4.1% smaller than the formatted version. Minify saves the most on queries with comments and stray whitespace (those are stripped); already-tight SQL barely shrinks further, which is expected.
How large can input be?
Up to 1,000,000 characters. Anything malformed is reported with the exact line and column instead of producing a broken file.

