SQL Formatter & Minifier
Beautify or minify SQL for Standard SQL, PostgreSQL, MySQL, SQLite, MariaDB and BigQuery, with indentation and keyword-case options, entirely in your browser.
SQL Formatter & Minifier — Paste a SQL query to beautify it with clean indentation and keyword casing, or switch to Minify to collapse it onto a single line. Pick the dialect that matches your database so clauses and functions are parsed correctly. Everything runs entirely in your browser and your queries are never uploaded.
What is SQL Formatter & Minifier?
A free online SQL formatter and minifier that runs entirely in your browser. Paste a messy or one-line query and Beautify mode re-indents it with 2-space, 4-space, or tab indentation and uppercases (or lowercases) the keywords for a readable layout; Minify mode strips comments and collapses the whitespace into a single compact line while leaving quoted strings untouched. Choose the dialect — Standard SQL, PostgreSQL, MySQL, SQLite, MariaDB, or BigQuery — so dialect-specific clauses and functions are parsed correctly. Backend developers, data analysts, and DBAs use it to tidy up hand-written queries, make ORM-generated SQL readable, and shrink statements before embedding them in code.
How to use SQL Formatter & Minifier
- Paste or type your SQL into the Input box.
- Open Settings and pick the dialect that matches your database: Standard SQL, PostgreSQL, MySQL, SQLite, MariaDB, or BigQuery.
- Leave the mode on Beautify to re-indent the query, or switch to Minify to collapse it onto one line.
- In Settings, choose 2-space, 4-space, or tab indentation and whether keywords are uppercased, lowercased, or left as written (Beautify mode).
- Read the formatted result and use the Copy button to grab it, or click Clear to empty the input and start over.
Examples
Beautify a one-line SELECT (2 spaces, UPPER keywords)
Input
select id, name from users where active = 1 order by name
Output
SELECT id, name FROM users WHERE active = 1 ORDER BY name
Minify a multi-line query for embedding
Input
SELECT id, name FROM users -- only active rows WHERE active = 1
Output
SELECT id, name FROM users WHERE active = 1
Format dialect-specific SQL
Pick PostgreSQL, MySQL, SQLite, MariaDB, or BigQuery before beautifying so dialect-specific keywords and functions (such as BigQuery backtick-quoted names or Postgres casts) are recognized and laid out correctly instead of being mistaken for an error.
Frequently asked questions
- Is my SQL uploaded to a server?
- No. Beautifying, minifying, and dialect parsing all happen locally in your browser using the sql-formatter library. Your queries never leave your device, and the tool keeps working offline.
- Which SQL dialects are supported?
- You can choose Standard SQL, PostgreSQL, MySQL, SQLite, MariaDB, or BigQuery. The dialect tells the formatter how to parse dialect-specific keywords, quoting, and functions so the layout stays correct.
- What's the difference between Beautify and Minify?
- Beautify re-indents the query and applies your chosen keyword case for readability, using the selected dialect's grammar. Minify removes comments and squeezes the statement onto a single line, leaving quoted strings and identifiers untouched.
- Can I control indentation and keyword case?
- Yes. In Settings you can pick 2-space, 4-space, or tab indentation, and set keywords to uppercase, lowercase, or preserve. These options apply in Beautify mode; Minify always collapses to one line.
- Why does it report a parse error?
- Beautify mode parses the query with the chosen dialect, so a genuine syntax problem or a statement written for a different dialect can fail to parse. Try switching to the matching dialect, or use Minify, which only tidies whitespace without parsing.
Related tools
Base32 / Base58 Encode / Decode
Encode text to Base32 (RFC 4648) or Base58 (the Bitcoin alphabet) and decode either one back to text, fully UTF-8 safe and entirely in your browser.
Base64 Encode / Decode
Encode text to Base64 or decode Base64 back to text (UTF-8 safe).
Case Converter & Counter
Change text case and count characters, words and lines.
Code Formatter & Minifier
Beautify or minify HTML, CSS and JavaScript instantly in your browser, with 2-space, 4-space or tab indentation and Terser-powered JavaScript compression.