SQL formatter. Format and beautify SQL queries for MySQL, PostgreSQL, SQL Server, BigQuery and more with customizable indentation.
100% browser-based — your data never leaves your device
Format and beautify SQL queries with customizable indentation.
SQL pulled out of logs, codebases, and quick scripts is often a single dense line that no one wants to read. This formatter turns that mess into properly indented, structured statements, with options that respect your team's conventions. Because it runs in your browser, the query never goes anywhere:
Code review is the biggest beneficiary. A query formatted consistently is far easier to review for correctness than a wall of text, so running pulled-out-of-context SQL through this formatter before a review saves everyone time and keeps discussions focused on the logic instead of the layout. The same applies to minified SQL recovered from logs or debugging output, which is effectively unreadable until it is expanded.
Team consistency is the second reason. When every developer formats queries through the same rules — the same indentation, the same keyword casing — diffs shrink to real changes and the codebase reads as if one person wrote it. The dialect support matters here: MySQL, PostgreSQL, SQL Server, Oracle, BigQuery, and standard SQL each have their own reserved words and syntax rules, and choosing the right dialect keeps the formatter from mangling dialect-specific constructs.
The SQL you format often tells a story about your database: table names, column names, and the relationships between them. Send that to an online formatter and you have effectively handed a third party a partial schema diagram of your system. This tool formats entirely in your browser, so your queries never leave your device.
That privacy makes it safe to format the real thing. Rather than sanitizing table names and column references before running them through a formatter, you can paste actual queries from production debugging sessions and get clean output without leaking your schema, your conventions, or anything else about your database to an outside service.
Copy your unformatted or minified SQL query and paste it into the input field.
Select your SQL dialect, choose tab or space indentation, and pick keyword case (upper or lower).
Click Copy to grab the beautified SQL, or download as a .sql file.
Practical examples to help you get the most out of SQL Formatter:
Input: SELECT * FROM users WHERE age > 18 ORDER BY name ASC LIMIT 10; Output: SELECT * FROM users WHERE age > 18 ORDER BY name ASC LIMIT 10;
Input: SELECT u.name, o.total FROM users u JOIN orders o ON u.id = o.user_id WHERE o.status = 'active'; Output: Formatted with proper indentation and line breaks for readability.
Different databases have different reserved words and syntax. Always select the correct dialect for your query (MySQL, PostgreSQL, etc.).
Re-formatting already readable SQL can sometimes introduce inconsistent spacing. Only format queries that are truly minified or poorly formatted.
MySQL, PostgreSQL, SQL Server, Oracle, BigQuery, Db2, Hive, MariaDB, Snowflake, and standard SQL.
No. All formatting happens locally. Your queries never leave your device.
Supports MySQL, PostgreSQL, SQL Server, Oracle, BigQuery, and standard SQL.
Choose tab or space indentation with configurable width.
Format keywords in uppercase or lowercase as preferred.
Copy formatted SQL to clipboard or download as .sql file.
SQL Formatter is useful in a variety of scenarios across different workflows:
Formatting SQL queries for code reviews and team collaboration
Beautifying minified SQL from logs and debugging output
Standardizing SQL formatting across a development team's codebase
Different SQL dialects have different syntax rules. Select the correct dialect for the most accurate formatting.
Uppercase keywords with lowercase identifiers is a widely adopted convention for readable SQL.
Explore more tools in the Database workspace: