SQL formatter
Paste a query to format it with clean indentation and consistent keyword case, or minify it to one line. Pick your database so its own syntax is understood.
How to format SQL
- Paste your query, or drop a
.sqlfile. It is formatted as you type. - Pick the dialect of your database, such as PostgreSQL, MySQL or SQL Server, so its own syntax (
TOP, backtick names,::casts,$$bodies) is read correctly. The choice is kept in the link, likenavaja.dev/sql#postgresql. - Choose UPPER, lower or unchanged keywords and an indent of 2 spaces, 4 spaces or tabs, then copy or download the result.
Minify SQL safely
Minify puts a query on one line for logs, config files or code strings. It removes comments and extra spaces but never touches text inside quotes, quoted names, [brackets] or $$ bodies, and it keeps MySQL /*! ... */ and Oracle /*+ ... */ hints. Backslash escapes inside strings follow the chosen dialect.
Private by design
Queries often contain table names, customer data or credentials. This formatter runs entirely in your browser, so nothing you paste is sent to a server or stored.
Questions
Which SQL dialects are supported?
Standard SQL, PostgreSQL, MySQL, MariaDB, SQLite, SQL Server (T-SQL), Oracle PL/SQL, BigQuery, Snowflake, Redshift, Spark, Hive, Trino/Presto, DuckDB, ClickHouse, Db2, SingleStore, TiDB and Couchbase N1QL.
Why do I get a parse error?
The query is probably missing a bracket or quote, or uses syntax from another database. Check the line and column in the message, or pick your database's dialect.
Does formatting change what my query does?
No. Only whitespace and, if you choose, the case of keywords change. Strings, names and values stay as they are. For ClickHouse, where names are case-sensitive, case is always kept.
Can I keep my keywords lowercase?
Yes. Choose lower, or Keep to leave each keyword exactly as you typed it.
Is my SQL uploaded anywhere?
No. Formatting and minifying happen in your browser, so you can paste queries with real data safely.
Does it format stored procedures?
Yes, for dialects with procedural syntax such as PL/SQL, T-SQL and PostgreSQL functions. Very unusual vendor syntax may need the closest dialect.