SQL formatter
Indent SQL and capitalize its keywords for readability, with a Minify option to compact a query back to one line.
Formatting result
Status
Ready to format
- Lines
- -
- Characters
- -
- Keywords recognized
- -
How it works
A SQL formatter re-indents a messy or minified query and capitalizes standard keywords like SELECT, FROM, WHERE, JOIN, GROUP BY and ORDER BY, breaking a multi-clause query onto readable lines.
- Paste your SQL
Replace the example query with your own.
- Choose the indent
2 spaces, 4 spaces or a tab. Uppercase keywords is on by default.
- Format, minify or download
Format re-indents in place, Minify compresses to one line, and Download saves the current text as a .sql file.
Scope and limits
The formatter recognizes standard ANSI SQL keywords: SELECT, FROM, WHERE, JOIN variants, GROUP BY, HAVING, ORDER BY, LIMIT, INSERT, UPDATE, DELETE, CREATE, ALTER and more. Text inside a single-quoted or double-quoted literal is left untouched, so a string like 'select all from here' or an identifier named "order" is never miscapitalized.
Dialect-specific syntax
Dialect-specific extensions, such as PostgreSQL's RETURNING clause, MySQL's LIMIT/OFFSET shorthand, or T-SQL's TOP and NOLOCK hints, are passed through without modification rather than formatted incorrectly. The formatter targets standard DML and DQL statements that work the same across MySQL, PostgreSQL and SQL Server.
Nothing leaves your device
Formatting runs entirely in your browser. Your query, including table names, column names and any embedded values, is never sent to a server, so it is safe to paste queries containing production table names or sensitive values.
Frequently asked questions
How do I format a messy one-line SQL query into readable code?
Paste the SQL into the input area and click Format. The formatter adds indentation and capitalizes standard keywords, breaking multi-clause queries onto separate lines: SELECT, FROM, WHERE and ORDER BY each start a new line, with AND, OR and ON indented beneath the clause they belong to.
Is my SQL query sent to a server when I use this formatter?
No. SQL formatting runs entirely in your browser. Your query, including table names, column names and any embedded values, never leaves your device. You can safely paste queries containing production table names or internal schema details.
Does the SQL formatter support multiple SQL dialects like MySQL, PostgreSQL and T-SQL?
The formatter recognizes and formats standard ANSI SQL keywords. Dialect-specific syntax such as PostgreSQL's RETURNING clause, MySQL's LIMIT/OFFSET shorthand or T-SQL's TOP and NOLOCK hints may not be reformatted; those pass through unchanged rather than being altered incorrectly.
When would I use the Minify option for SQL?
Minifying removes whitespace and newlines to compress a query to the smallest possible string. This is useful when embedding SQL inside application code as a string literal, storing queries in configuration files with size limits, or comparing two queries after stripping formatting differences.
Will the formatter change my column or table names if they match a keyword?
Only outside quotes. Keyword matching skips anything inside single or double quotes, so a column named "order" or a string containing the word "select" is left exactly as written. Always review the formatted output before using it in production to confirm nothing was altered unexpectedly.