SQL Formatter
Paste a query to get clean, indented SQL, or switch to Minify to put it on one line. Choose your database dialect so its syntax is read correctly.
- Runs on your device
- No sign-up
- Free, no watermark
How to use the SQL Formatter
- 01Paste your SQL into the input, or open a .sql file.
- 02Pick the dialect your database uses.
- 03Choose Format and set the keyword case and indent, or choose Minify.
- 04If the query can't be parsed, the status bar shows the line and column.
- 05Copy the result, download it as a .sql file, or replace your input with it.
Good to know
Runs on your device
Queries are formatted in your browser, so table names and data in them stay private.
20 dialects
Standard SQL, MySQL, PostgreSQL, SQL Server, SQLite, MariaDB, Oracle PL/SQL, BigQuery, Snowflake and more.
Your style
Uppercase, lowercase or as-typed keywords, 2 or 4 spaces or tabs, and 1 or 2 blank lines between queries.
Safe minify
Whitespace is collapsed, but strings, quoted names and comments are left exactly as written.
Frequently asked questions
Is my SQL sent to a server?
No. Formatting runs in your browser with the open-source sql-formatter library. Your queries never leave your device.
Why does it say my SQL couldn't be parsed?
The formatter reads the query before laying it out, so an unclosed bracket or quote, or syntax from another database, stops it. Check the line shown, or pick the dialect the query was written for.
Does formatting change what my query does?
It changes whitespace and, if you choose, the case of keywords, built-in functions and data types. Table and column names, strings and numbers are not changed.
Is Minify safe for strings and comments?
Yes. Text in quotes, quoted or bracketed names and $$ bodies are copied exactly. Comments are kept unless you turn on Remove comments; a -- comment keeps its line break so it can't swallow the rest of the query. Optimizer hints such as /*+ ... */ and MySQL /*! ... */ are always kept.
Which dialect should I choose?
The database the query runs on. If it isn't listed, Standard SQL works for most queries.