Skip to main content
ToolsBay

Runs in your browser — nothing is uploaded · verify

SQL Formatter — free, and it runs in your browser

Indent and align SQL for PostgreSQL, MySQL, SQLite, BigQuery, Snowflake and SQL Server, with keywords capitalised.

  • Indent and align a query so you can read it during a review or an incident.
  • Supports the major dialects — Postgres, MySQL, SQL Server, SQLite, BigQuery and more.
  • Keywords, joins and nested subqueries are laid out consistently.

Your query

Tab indents · Esc then Tab to leave1 line

Formatted query

1 line
  • 70 tools

    Free, with no account and no watermark

  • 0 bytes

    Of your files or text uploaded — this tool runs in the tab

  • No queue

    The work happens in this tab, not in a line behind other users

Three steps, nothing to install

SQL Formatter in three steps

  1. SQL123456Paste it in — it never leaves the tab

    Paste the query

    A one-line monster out of a log, or a query someone else wrote three years ago.

  2. SQLSQLConverted on your own device

    Choose the dialect

    Formatting rules differ between engines, so the dialect is a setting rather than a guess. Clauses, joins and subqueries are aligned to depth.

  3. Copy SQL

    Copy the readable version

    Paste it into a review, a runbook or your editor.

Why use SQL Formatter

  • Dialect-aware

    Reserved words and quoting rules are not the same across engines. Formatting Postgres as if it were SQL Server is how a formatter mangles an identifier.

  • Handles real-world sizes

    Large documents are processed in one pass without pagination or a cut-off, so you are not left wondering which half of the input arrived.

  • Your text stays in the page

    What you paste is not transmitted or stored, so an API response full of customer records, a token or an internal query never leaves your machine.

Frequently asked questions

Each database adds its own syntax — PostgreSQL has ::casts and $$ blocks, SQL Server uses [bracketed] identifiers, BigQuery uses backticks and array types. Picking the right dialect avoids the formatter mangling syntax it does not recognise.

Why SQL formatting matters more than it looks

SQL is written as one long expression, and a query of any complexity becomes unreadable the moment it exceeds a couple of lines. A well-formatted query puts each clause on its own line, indents joins under the tables they attach to, and lines up conditions so the logic is visible at a glance.

That readability is not cosmetic. The most common SQL bugs — a join condition in the WHERE clause instead of ON, a missing parenthesis around an OR, a GROUP BY that omits a selected column — are obvious in formatted output and nearly invisible in a single-line query.

Dialects

Standard SQL is a specification that no database implements exactly. PostgreSQL, MySQL, SQLite, SQL Server, BigQuery and Snowflake each extend it in ways that a generic parser does not recognise. Selecting your dialect means the formatter understands the syntax rather than treating it as an unparseable token.

When your query returns JSON, the JSON formatter will make the result readable, and JSON to CSV will turn it into a spreadsheet.

  • JSON Formatter

    Pretty-print JSON with the indentation you choose, or minify it.

  • JavaScript Formatter

    Format JavaScript and TypeScript with Prettier in your browser.

  • YAML Validator

    Validate YAML syntax and preview the parsed result as JSON.

  • HTML Beautifier

    Re-indent minified or messy HTML into readable markup.

  • CSS Minifier

    Strip comments and whitespace to shrink a stylesheet.

  • URL Parser

    Break a URL into its protocol, host, path and query parameters.

More tools

70 tools, none of which want your file

Everything this tool does happens in the page you are looking at. No account, no upload, no watermark.