Developer Tools

SQL Formatter

Format SQL queries locally with dialect-aware indentation and keyword casing. Choose PostgreSQL, MySQL, SQLite, SQL Server and more, then copy or download the result. Queries are never executed.

Your content stays on your device Free, with no account
Give your queries room to breathe Local formatting · no execution
Up to 100,000 UTF-16 units. Select the dialect used by your query.
Expression width affects parenthesized groups; it is not a maximum line length.

No database connection is made. A successful format is not proof that SQL is valid or safe to run. Stored procedures and custom statement delimiters are not supported.

FORMATTED SQL

Ready. Paste a query and choose its dialect.

Formatting runs in a cancelable worker with a 5-second limit. Comments and literals are handled by the selected dialect; review the result before use. Placeholders are not replaced. No input history is saved.

A FEW SIMPLE STEPS

How to use SQL Formatter

  1. Paste your SQL and select the dialect matching your database.
  2. Choose indentation, keyword casing, parenthesized expression width and statement spacing.
  3. Select Format SQL. Stop cancels the local worker; edits also discard pending output.
  4. Review the result, then copy it or download a .sql file. Formatting does not validate or execute a query.
PRIVATE BY DESIGN

Why use this tool?

Your SQL is never uploaded to any server; formatting is completed locally in your browser. A bundled open-source formatter runs in a cancelable worker, with no database connection, account or query history. Copy and download happen only when you choose.

Tool inputs stay in your browser. Only your theme preference is saved on this device.

A few things worth knowing

Does this execute SQL or connect to a database?

No. The tool formats text locally. It never connects to a database, executes queries or sends your SQL to a server. A successful format does not prove SQL is valid, supported by your database or safe to run.

Which dialects can I choose?

The tool exposes 20 dialect choices from SQL Formatter 15.9.0, including Standard SQL, PostgreSQL, MySQL, SQLite, SQL Server, MariaDB, BigQuery, Snowflake and DuckDB. Select the actual dialect instead of relying on automatic detection. Dialect coverage has limits; stored procedures and custom statement delimiters are not supported.

Does keyword casing rename my columns or change values?

Only keyword casing is configurable. Identifier, data type and function-name casing are configured to preserve their spelling. The formatter handles literals and comments according to the chosen dialect, and placeholders are not substituted. Review the output before use: this is a formatter, not a semantic equivalence checker.

What does expression width mean?

It controls how parenthesized expressions are kept together or expanded. It is not a maximum length for every line. The smallest width of one encourages groups to expand. Statement spacing inserts one or two blank lines between semicolon-separated queries.

Why did formatting fail or stop?

Check the dialect first. Invalid tokens, unsupported syntax or tool limits may cause a failure. Input is limited to 100,000 UTF-16 units, output to 1,000,000, and processing to five seconds in a local worker. Stop, edits and leaving the page terminate pending work; no partial result is exported.

Are comments and formatting-disable sections supported?

The underlying formatter handles comments and recognizes sql-formatter-disable and sql-formatter-enable block-comment directives, which bypass formatting for enclosed text. Such bypassed sections are not parsed. Formatting errors are not a complete SQL validation report. The local bundle includes its MIT license and attribution.