Quick Answer
A SQL formatter rewrites your query with consistent indentation, line breaks, and keyword casing so it is readable and easy to review. This free SQL formatter at https://practicalwebtools.com/dev-tools/code/sql-formatter handles Standard SQL, PostgreSQL, MySQL, MariaDB, SQLite, and Transact-SQL, indents with 2 or 4 spaces, uppercases keywords, and can minify a query onto one line. It runs entirely in this browser tab — your SQL is never uploaded.
How It Works
Paste your SQL into the input box — one statement, several statements, or a query with CTEs and JOINs
Pick the dialect, indent width, keyword casing, and pretty or minified output
Read the line-numbered result and copy it — the output updates live as you type
Key Facts
- Six dialects: Standard SQL, PostgreSQL, MySQL, MariaDB, SQLite, and Transact-SQL
- Live formatting — the output updates as you type, with no button to press
- Choose 2-space or 4-space indentation, and keep or uppercase keywords
- Minify mode collapses a query onto one line for logs, URLs, or embedding
- Line numbers in the output keep long queries easy to review and discuss
- Parse errors are reported inline with line and column — no silent mangling
- Runs entirely in this browser tab: your SQL is never uploaded
Frequently Asked Questions
Which SQL dialect should I pick?
The formatter is largely dialect-agnostic, so plain queries format identically in every mode. The dialect matters for vendor-specific syntax: PostgreSQL casts (::), dollar-quoted strings, and RETURNING; MySQL and MariaDB backtick identifiers; Transact-SQL batches and TOP. If a query uses none of those, Standard SQL is the right choice. If formatting fails on vendor syntax, switch the dialect to match the database the query came from.
What does minify mode do?
Minify collapses the formatted query onto a single line: every newline and its indentation becomes one space, so multi-statement pastes become one line separated by semicolons. This is what you want for logs, URLs, or embedding a query as a string in code. It only removes whitespace the formatter would add — identifiers, literals, and keywords are untouched.
Does the formatter validate my SQL?
No. Formatting is not parsing for correctness — a query with a logic error still formats cleanly. Some malformed input (like an unterminated string) makes the parser throw, and this tool shows that error inline with its line and column. A query that formats without error can still be wrong, so test-run it before it reaches production.
Does formatting change what my query does?
No. The formatter changes whitespace, line breaks, and keyword casing only. Identifier casing is preserved exactly as you wrote it, string literals keep their contents, and clause order is never rearranged — the output means the same thing to the database as the input.
Is my SQL sent anywhere?
No. All formatting happens locally in this browser tab with a JavaScript port of the formatter — you can watch the Network tab stay quiet while you type. Nothing is uploaded, logged, or stored; closing the tab discards everything.