SQL Formatter
Beautify SQL queries with consistent indentation, one column per line and optional upper-case keywords.
The formatter works on tokens, so strings, quoted identifiers and comments are never changed.
Readable SQL
Long queries generated by ORMs, copied from logs or written on one line are hard to read and debug. The SQL Formatter arranges your query by structure: every major clause (SELECT, FROM, WHERE, GROUP BY, ORDER BY), joins, subqueries and CASE expressions get their own lines.
Safe editing
The query is tokenised first, so string values, quoted identifiers and comments are never altered. Optionally upper-case keywords and put every column on its own line.
Dialect support
Standard SQL plus common MySQL, PostgreSQL, SQL Server and SQLite syntax are supported. Your query is processed in the browser, so table names and data aren't sent anywhere.
How to use SQL Formatter
- Paste your SQL query.
- Set the keyword case and indentation options.
- Review the formatted query.
- Copy the result.
Why use this tool?
Produces consistent, readable SQL for code reviews, documentation and debugging.
FAQ
Which SQL dialects are supported?
Standard SQL plus common MySQL, PostgreSQL, SQL Server and SQLite syntax. Unusual vendor-specific syntax is kept as written.
Does it run my query?
No, it only formats; it never connects to a database.
Can it format stored procedures?
It formats the basic statements; some lines in complex procedural blocks may stay as written.
Related tools
JSON Formatter and Validator
Pretty-print messy or minified JSON and find errors with line and column details.
Open toolXML Formatter and Validator
Indent XML documents for readability and check that they're well-formed.
Open toolHTML Minifier
Safely remove comments and extra whitespace between tags to shrink your HTML.
Open toolJSON to C# Class Generator
Generate C# classes or records from JSON with nested types, List<T>, nullable types and [JsonPropertyName].
Open tool