What is a SQL formatter?
A SQL formatter rewrites a database query with consistent line breaks, indentation and keyword capitalisation so its structure is easy to read. Queries copied out of application logs, ORMs and BI tools usually arrive as one enormous line, which makes joins and conditions hard to follow and bugs easy to miss.
Formatted SQL is easier to review in pull requests, explain to colleagues and paste into documentation. This formatter supports the major dialects, lets you choose uppercase or lowercase keywords and two spaces, four spaces or tabs, and can minify a query back to one line. Your SQL is processed in the browser, never sent anywhere.
How to use the SQL Formatter
1.Paste the SQL
One query or several separated by semicolons.
2.Pick the dialect and style
Choose your database, keyword case and indent size.
3.Copy or download
Save it as a .sql file or copy it back into your editor.
Example: a one-line report query
A query joining orders, customers and items with a WHERE, GROUP BY, HAVING, ORDER BY and LIMIT, formatted as Standard SQL:
- Lines
- 1 → 20
- Keywords
- select, from, join → SELECT, FROM, JOIN
- Conditions
- each AND on its own indented line
- Strings
- '2026-01-01' and ('IN', 'US') unchanged
Each clause starts a new line, making the two joins and the HAVING condition easy to check.
Dialect-aware formatting
Databases differ: MySQL quotes names with backticks, SQL Server uses brackets, PostgreSQL has :: casts and dollar-quoted strings. Choosing the right dialect lets the formatter recognise these instead of breaking them. Main clauses like SELECT, FROM, WHERE and GROUP BY start new lines, and columns and conditions are indented beneath them.
Minify keeps string literals and quoted identifiers exactly as written, removes -- and /* */ comments and collapses whitespace, which is handy for logging a query or pasting it into code. Formatting never changes what the query does.
Frequently asked questions
Does formatting change my query's results?
No. Only whitespace and, if you choose, keyword capitals change. Strings and names are untouched.
Does it check that my SQL is valid?
Not fully. It formats what it can parse; a typo such as SELEC may be formatted without a warning.
Are comments kept?
Formatting keeps them. Minifying removes them, so nothing after a -- comment can swallow the rest of the line.
Which databases are supported?
Standard SQL, MySQL, MariaDB, PostgreSQL, SQLite, SQL Server, Oracle PL/SQL, BigQuery, Snowflake, Redshift and Spark SQL.
Related tools
CSV & JSON to SQL INSERT Generator
Turn CSV or JSON rows into SQL INSERT statements.
SQL IN Clause Generator
Turn a list of values into a SQL IN (…) clause.
JSON Formatter & Validator
Pretty-print, minify, sort and validate JSON with line-numbered errors.
HTML Beautifier & Minifier
Indent messy HTML or minify it for production.
CSS Beautifier & Minifier
Format CSS readably or minify it safely.
JavaScript Beautifier & Minifier
Format JavaScript, or minify it with Terser.
More Developer tools
JSON & data
CSV tools
Network & system
Web & API
Git & releases
Encoding & security
- Base64 encode & decode
- URL encode & decode
- JWT decoder
- Hash generator
- HTML entity encoder
- Text to binary
- Morse code translator
- Caesar cipher & ROT13
- Random string generator
- Secret key generator
- 2FA code generator (TOTP)
- Encrypt & decrypt text
- Encrypt & decrypt files
- SSH key generator
- Base32 encoder and decoder
- Unicode escape converter
- Nano ID generator
- JWT generator
Text & code
- Regex tester
- Text diff checker
- Cron expression explainer
- Lorem ipsum generator
- Markdown previewer
- Slug generator
- Strip HTML tags
- Unicode character inspector
- URL parser
- Markdown TOC generator
- cURL converter
- Whitespace visualizer
- Markdown link extractor
- Regex escape
- Regex match extractor
- Split text by regex
- HTML, CSS and JS playground
- Mock data generator
- Keyboard event tester
- ASCII table