SQL Formatter

Beautify or minify SQL for T-SQL, PostgreSQL, MySQL, SQLite and more.

Runs locally · nothing uploaded
SQL
Result

What it does

Paste a query copied from a log, an ORM trace or a stored procedure and get it back readable: one clause per line, indented joins and subqueries, consistent keyword case. It reformats as you type.

Features

  • Dialect-aware: SQL Server (T-SQL) is the default, with @variables, #temp tables, [bracketed names], N'unicode' strings and GO separators. PostgreSQL ($1 parameters, :: casts, $$ strings), MySQL, MariaDB, SQLite, standard SQL, Oracle PL/SQL, Snowflake and BigQuery are also supported.
  • Keyword case: UPPER, lower or preserved, optionally applied to function names and data types as well.
  • Indent with 2 or 4 spaces or tabs, a standard or tabular layout, blank lines between statements and dense operators.
  • Minify collapses a query onto as few lines as possible for logs or config files. It removes comments but keeps string contents, quoted identifiers, optimizer hints (/*+ ... */) and T-SQL GO lines intact.
  • Clear errors: if the query can’t be parsed in the selected dialect you get the line, column and a snippet with a caret, often a hint that a different dialect is needed.

How to use it

Pick the dialect, paste or drop a .sql file and copy or download the result. Ctrl+Enter formats immediately. Formatting uses the open-source sql-formatter library; procedural code (BEGIN ... END blocks) and table hints such as WITH (NOLOCK) stay valid but are laid out more simply than plain queries.

Privacy

Your SQL is formatted in your browser and never sent anywhere. The last input is kept in local storage so a refresh doesn’t lose it.