🔒 Runs in your browser — nothing is uploaded✓ Free, no signup
SQL Formatter — Beautify SQL Queries Online
Turn long one-line SQL into readable, indented queries. Choose your database dialect, indentation and keyword case — or minify SQL back to one line.
0 characters
When should you use the SQL Formatter?
- Reading a long query copied from logs, an ORM or a slow-query report
- Cleaning up SQL before a code review or putting it in documentation
- Minifying SQL to embed it in a config file or a single log line
How to use the SQL Formatter
- 1
Paste your SQL
Paste one or more statements into the input editor, or click Load sample.
- 2
Choose the dialect
Select your database so dialect-specific syntax such as T-SQL brackets or PostgreSQL :: casts is understood.
- 3
Set indentation and keyword case
Pick 2 spaces, 4 spaces or tabs, and whether keywords should be UPPERCASE, lowercase or kept as typed.
- 4
Format or minify, then copy
Click Format SQL for readable output or Minify for a single line, then use Copy Output.
Examples
One-line query to readable SQL
Before
select id, name from users where status = 'active' and age > 18 order by name
After
SELECT id, name FROM users WHERE status = 'active' AND age > 18 ORDER BY name
Common errors and how to fix them
Parse error at token- The selected dialect does not recognise some syntax. Switch to your actual database (e.g. PostgreSQL or SQL Server) and format again.
Template placeholders like {{id}} or :name break formatting- Replace them with a literal value or ? before formatting, then put the placeholders back.
Keywords used as column names become uppercase- Quote the identifier ("order", `order` or [order]) or set Keywords to 'Keep as typed'.
Explore More Developer Tools
Format, Validate, and Generate Data Instantly
TrueFormatter provides essential utilities for modern web development, including JSON formatting, YAML conversion, and more.
JSON Auto-Fixer & Formatter
Repair, validate, and beautify broken JSON (missing quotes, trailing commas).
JSON Validator & Linter
Check JSON syntax and see the exact line and column of every error.
JSON Beautifier
Pretty-print and indent JSON for easy reading and debugging.
JSON Compare & Diff Tool
Find the difference between two JSON objects visually and quickly.
JSONPath Tester
Evaluate JSONPath expressions with filters and recursive queries.
JSON Schema Generator
Generate a JSON Schema from any sample JSON document.
JSON to CSV Converter
Flatten nested JSON arrays into CSV for spreadsheets.
YAML ⇆ JSON Converter
Convert YAML to JSON or JSON to YAML instantly.
JWT Decoder
Decode and inspect JSON Web Tokens (JWT) Header and Payload.
JWT Generator
Create and sign HS256/HS384/HS512 JSON Web Tokens for testing.
Hash Generator (MD5, SHA)
Generate MD5, SHA-1, SHA-256, SHA-384 and SHA-512 hashes.
Base64 Encoder ⇆ Decoder
Encode text to Base64 and decode Base64 to text for API debugging.
URL Encoder & Decoder
Cleanly encode special characters in URLs and decode query strings.
SQL Formatter & Beautifier
Format SQL queries for MySQL, PostgreSQL, SQL Server, SQLite and more.
CSS Minifier & Compressor
Optimize CSS by removing whitespace and comments to accelerate page load time.
JS Minifier & Compressor
Compress JavaScript to improve website speed and performance.
Regex Tester & Debugger
Test JavaScript regular expressions with live match highlighting and groups.
Cron Expression Generator
Build cron schedules, read them in plain English and preview next runs.
UUID / GUID Generator
Generate unique V4 UUIDs for database keys or testing.
Epoch converter online
Convert UNIX timestamps to human-readable dates and back instantly.
Crop Image Online
Crop images exactly as selected with fixed aspect ratios. No upload, no resize, no quality loss.
Compress Image Online
Compress JPG, PNG & WebP images directly in your browser. No upload, no tracking, instant download.
SQL Formatter FAQ
Standard SQL, MySQL, MariaDB, PostgreSQL, SQL Server (T-SQL), SQLite, Oracle PL/SQL, BigQuery, Snowflake, Redshift and Spark SQL. Pick the one that matches your database so dialect-specific syntax is recognised.
No. Only whitespace, line breaks and keyword case change. Table names, column names, string values and the query logic stay exactly the same.
SQL is case-insensitive for keywords, so it is a style choice. Uppercase keywords (SELECT, FROM, WHERE) are the most common convention because they stand out from table and column names.
The formatter could not understand part of the query. Usually the wrong dialect is selected (e.g. T-SQL brackets or PostgreSQL :: casts under Standard SQL), or the query is incomplete. Try switching the dialect.
Yes. Separate statements with semicolons and each is formatted with a blank line between them.
It removes comments and extra whitespace to put the query on one line, which is handy for logs, config files or embedding SQL in code. String literals are left untouched.
