Skip to content

SQL Formatter

To format SQL online, paste your query, pick a dialect — PostgreSQL, MySQL, T-SQL, Oracle PL/SQL, Snowflake or BigQuery — and choose 2 spaces, 4 spaces or tabs. SQL Formatter re-indents SELECT, JOIN and WHERE clauses and normalises keyword case. It runs in your browser, so queries are never uploaded or executed. Copy the result.

Updated

Paste a SQL query — SELECT, INSERT, UPDATE, DELETE, or common DDL — and format it locally for readable indentation and consistent keyword casing. Closing the tab drops the workspace; we do not write the query to localStorage or send it to a formatter API. This page is a SQL beautifier / pretty-printer for text you already have, not a database client and not a query runner.

Fifteen dialect presets cover standard SQL, PostgreSQL, MySQL, MariaDB, SQLite, T-SQL / MSSQL, Oracle PL/SQL, BigQuery, Snowflake, Amazon Redshift, Spark SQL / Databricks, Trino / Presto / Athena, DuckDB, ClickHouse, and IBM Db2 as formatter options only. Dialect choice changes how the formatter reads quoting, parameters, and keywords; it does not connect to a server or validate against a live schema. If the chosen dialect cannot parse your paste, the error names the dialects that can — square-bracket names point to T-SQL, :: casts to PostgreSQL, backticks to MySQL.

SQL workspace

Changes indentation and keyword handling in the formatter. Does not connect to a server or validate a schema.

2 spaces, 4 spaces, or a Tab per level.

Applies to recognized SQL keywords, not string literals.

Paste any query text. Formatting runs in this tab with sql-formatter — layout dialect only, not a live database connection.

Output

Pretty-printed SQL will appear here.

How does the SQL Formatter work?

  1. 1. Paste SQL

    Drop in a query or script fragment. An example is available from Load example.

  2. 2. Choose dialect

    Pick a layout dialect (PostgreSQL, MySQL, T-SQL, Oracle PL/SQL, Snowflake, and others) and an indent: 2 spaces, 4 spaces, or Tab. If the dialect cannot parse the paste, the error suggests one that can.

  3. 3. Format locally

    The browser runs sql-formatter in this tab. Nothing is uploaded.

  4. 4. Copy the result

    Copy readable SQL for review or a diff. Closing the tab clears the workspace.

Questions about SQL Formatter

Does SQL Formatter upload my queries?
No. Formatting runs in the browser with the sql-formatter library. There is no account and no server-side formatter. The text you paste stays in this tab until you clear it or close the page. We do not write it to localStorage.
Does this page run SQL against a database?
No. It only pretty-prints query text. There is no connection string, no execute button, and no network call to a database. Treat output as formatted text for reading — not a result set.
Which SQL dialects are supported?
Fifteen: standard SQL, PostgreSQL, MySQL, MariaDB, SQLite, T-SQL / MSSQL, Oracle PL/SQL, BigQuery, Snowflake, Amazon Redshift, Spark SQL / Databricks, Trino / Presto / Athena, DuckDB, ClickHouse, and IBM Db2 — all built into the sql-formatter library. Dialect changes how quoting, parameters, and keywords are read; it does not prove the query will run on a specific server version. If your paste fails in one dialect, the error lists up to three others that parse it.
Can I indent SQL with tabs or 4 spaces?
Yes. The Indent menu offers 2 spaces (the default), 4 spaces, or Tab — one tab character per nesting level, the same as sql-formatter's useTabs option. Indent only changes leading whitespace; keywords, identifiers, and string literals are untouched.
Can I pretty-print SQL with Prettier or from the command line?
Prettier does not format SQL on its own; it needs a community plugin such as prettier-plugin-sql. Without Prettier, the sql-formatter npm package ships a command-line tool: with Node.js installed, run npx sql-formatter -l postgresql query.sql to print the formatted query, or add --fix to rewrite the file in place. This page runs the same sql-formatter library in your browser with nothing to install.
Can it fix broken or incomplete SQL?
No. If the formatter cannot parse the text, you will see an error next to the input. Fix syntax in an editor and paste again. The page does not invent missing clauses or rewrite business logic.
Is this the same as a SQL linter or EXPLAIN tool?
No. This is a beautifier / pretty-printer for readable indentation and keyword casing. It does not lint style rules beyond formatting, estimate cost, or show query plans.
What about very large scripts?
The page is meant for typical queries and short scripts. Multi-megabyte dumps may strain the tab; keep huge migrations on a local CLI. There is no upload size limit because nothing is uploaded — the limit is browser memory and UI responsiveness.
Does keyword uppercasing change my string literals or identifiers?
Keyword case options apply to SQL keywords the formatter recognizes. String literals and quoted identifiers should keep their content; if a dialect option surprises you, switch dialect or choose preserve (when available) and re-copy.
How is this different from JSON Formatter on this hub?
JSON Formatter pretty-prints or minifies JSON with JSON.parse / JSON.stringify. SQL Formatter pretty-prints SQL query text with a SQL-aware layout engine. They share the same privacy rule (local only) but accept different languages.

These tools run in your browser. Page Utils does not store, upload, or write to localStorage the keys, tokens, or text you paste. Results are a convenience aid, not legal, tax, or security advice.