SQL formatter

Well formatted SQL makes reviews quicker and handovers easier.

Private: your files never leave this deviceNothing is uploaded or stored on a serverWorks right here in your browser

Thanks
Mode

How to format SQL

  1. Paste or open

    Paste SQL into the Input pane, open a .sql file, or drop one on the pane. Sample loads an example query.

  2. Pick dialect and style

    Choose your database's dialect, keyword case, indent and blank lines between statements. Minify puts everything on one line instead. The output updates as you type.

  3. Copy or download

    Press Copy, or Ctrl+C (Cmd+C on Mac) with nothing selected, to copy the whole result. Download saves it as a .sql file.

Good to know

  • Pick the dialect first: it decides how quotes, backticks, [brackets], $$ bodies and # comments are read.
  • Keywords set to As typed leaves your capitalisation alone and only fixes layout.
  • A parse error shows the line and column; Go to error selects that spot in the input.
  • Minify strips comments and line breaks but keeps every string, quoted name and optimiser hint exactly as written.
  • Everything runs in your browser. Nothing is uploaded.

Questions people ask

Which SQL dialects are supported?

Standard SQL, MySQL, MariaDB, PostgreSQL, SQL Server (T-SQL), Oracle PL/SQL, SQLite, BigQuery, Snowflake, Redshift, Spark, Hive, Trino and Presto, DuckDB, ClickHouse, Db2, Db2 for IBM i, Couchbase N1QL, SingleStore and TiDB. Pick the one your query is written for so its quoting, operators and keywords are read correctly.

Why does it say it cannot parse my SQL?

The formatter reads the query with the rules of the chosen dialect. Backtick identifiers need MySQL or a similar dialect, [bracketed] names need SQL Server, and $$ bodies need PostgreSQL. The message names the line and column, and Go to error selects that spot. Minify never fails, because it only removes whitespace and comments.

Does formatting change what the query does?

No. Only whitespace, line breaks and the case of keywords change. Strings, quoted names and comments are kept as they are. Minify also drops comments, except MySQL /*! */ blocks and /*+ */ optimiser hints, which can change a plan.

Can I format a large dump?

Yes. Files over 2 MB stay out of the editor and a background worker reads them from disk, so the page stays responsive. Very large scripts take a few seconds; the first 1 MB of the result is shown and Download saves all of it.

Is my SQL uploaded?

No. Formatting runs in a web worker inside your browser with the open-source sql-formatter library. Nothing is sent to a server.

Say thanks