Why format SQL?
Queries copied from logs, ORMs or a colleague's chat message usually arrive as one long line. Formatting puts each clause on its own line, indents joins and subqueries, and lines up conditions, so you can see at a glance what a query selects, how tables are joined and where a filter is missing. It also makes code reviews and diffs of SQL files much easier to read.
How to use it
- Paste one query or a whole script. Separate statements with semicolons.
- Choose your database under Dialect. This matters for syntax that only some databases have, such as PostgreSQL's
::casts and$$function bodies, SQL Server's[square brackets]andTOP, or MySQL's backticks. - Pick the keyword case and indentation your team uses. The result updates as you type.
- Copy the result, download it as a
.sqlfile, or click Minify for a single-line version.
Formatting styles
- Standard puts each clause keyword on its own line and indents what follows. It's the most common style in open-source projects.
- Tabular, left and right place keywords in a fixed-width column so the column names and conditions line up vertically, a style many data teams prefer for long analytical queries.
- AND / OR at the start of the line makes it easy to comment out one condition while debugging.
When to minify SQL
Minifying removes comments and extra whitespace while leaving string values and quoted names untouched. It's handy for putting a query into a JSON config, a log message or a single-line environment variable. Keep the formatted version in your repository; minified SQL is hard to review.
Your queries stay private
Formatting runs entirely in your browser, so table names, customer data in WHERE clauses and connection details are never sent to our server. Your last query is remembered in this browser only.
Frequently asked questions
Which databases are supported?
Standard SQL, MySQL, MariaDB, PostgreSQL, SQL Server (T-SQL), Oracle PL/SQL, SQLite, BigQuery, Snowflake, Amazon Redshift, Spark SQL, Hive, Trino/Presto, IBM Db2, SingleStore, TiDB and Couchbase N1QL.
Does formatting change what my query does?
No. Only whitespace and, if you choose, the letter case of keywords change. String values, quoted identifiers and comments are kept exactly as written.
Why do I get a parse error?
The formatter needs to understand the syntax, so an unclosed quote or bracket, or syntax from a different database, stops it. Check the dialect first: for example, square-bracket names only work with SQL Server selected.
Can it format stored procedures?
It formats the SQL statements inside them. Procedural blocks in PL/SQL and T-SQL are handled on a best-effort basis; very long procedures with vendor-specific control flow may keep some of their original layout.
Is my SQL sent to your server?
No. The formatter runs in your browser and nothing is uploaded.