SQL Formatter
Paste a query and get it neatly indented, with keywords in the case you like — or squeezed onto one line.
At a glance
- Formats queries for 11 dialects: Standard SQL, MySQL, MariaDB, PostgreSQL, SQL Server (T-SQL), Oracle (PL/SQL), SQLite, BigQuery, Snowflake, Redshift and Spark SQL — with each one’s quoting and operators.
- Puts every clause on its own line, indents joins and conditions, and keeps comments where they belong.
- Choose UPPER, lower or original case for keywords, functions and types; 2 or 4 spaces or tabs; a standard or tabular layout; and AND/OR at the start or end of lines.
- Minify to a single line without comments — strings, quoted names and dollar-quoted bodies are never touched.
- Syntax-coloured output with line numbers, clear error messages with the line and column, and copy or download as .sql.
- Runs in your browser — your queries, table names and data never leave your device.
Step by step
How to format SQL online
- 1
Paste your query
Paste SQL into the left box or open a .sql file.
- 2
Pick the dialect
Choose your database so its syntax is understood.
- 3
Set your style
Choose the keyword case, indentation and layout.
- 4
Copy the result
Copy the formatted SQL or download it — or switch to Minify for one line.
Features
Everything you need, nothing you don’t
11 SQL dialects
From MySQL and PostgreSQL to T-SQL, PL/SQL and BigQuery.
Your style
Keyword case, indentation, layout and operator spacing.
Minify
One line, comments removed, strings left intact.
Errors pinpointed
The line and column that couldn’t be parsed.
Files
Open .sql files; copy or download the result.
Private
Queries stay on your device.
Before and after
select o.id, sum(i.qty*i.price) total from orders o join order_items i on i.order_id=o.id where o.status='paid' group by o.id order by total desc becomes a query with SELECT, FROM, JOIN, WHERE, GROUP BY and ORDER BY each on their own line and their contents indented beneath — far easier to read, review and debug.
Common SQL style choices
| Choice | Why |
|---|---|
| UPPER-CASE keywords | Separates the SQL language from your table and column names at a glance. |
| One clause per line | Diffs and code reviews show exactly what changed. |
| AND / OR at line start | Easy to comment out or reorder conditions. |
| Tabular layout | Lines keywords up in a column, popular in data teams. |
| Minified | For embedding in code, logs, or URLs where whitespace gets in the way. |
FAQ
Frequently asked questions
Is my SQL sent to a server?
Which SQL dialect should I choose?
name in MySQL), operators (->> in PostgreSQL) and keywords; Standard SQL works for most simple queries.Why do I get a parse error?
Does it change what my query does?
Can it format stored procedures and several statements?
What library does it use?
Keep going
Related tools
JSON Formatter & Validator
Format, validate, minify and repair JSON online. Get the exact line and column of every error, a collapsible tree view and sorted keys — private, in-browser.
CSV to JSON Converter
Convert CSV or data pasted from Excel to JSON: auto-detected delimiter, real numbers and true/false, nested objects from dotted columns. Free, no upload.
Regex Tester
Free online regex tester: live match highlighting, groups, replace, a plain-English explanation, unit tests and code for Python, PHP, Java, C# and Go.
Text Compare
Compare two texts and see every difference: added, removed and changed lines with the changed words highlighted, side by side or inline. Free and private.
JSON to TypeScript
Generate TypeScript interfaces, types or Zod schemas from JSON online. Finds optional properties, unions and nested types. Free, private, no upload.
XML to JSON Converter
Convert XML to JSON and JSON to XML online. Keeps attributes, arrays and leading zeros intact, shows exact error lines and never uploads your data.
Last updated Report a problem or suggest a feature