BrainCoder
DeveloperNothing uploaded

SQL Formatter

Re-indent a query, or be told why it can't be

Free forever — no sign-up, nothing uploaded. Files never leave your device.

braincoder.app/use/sql-formatter

SQL Formatter

Re-indent a query, or be told why it can't be

Drop your file here

or browse from your device

Browse files

document.pdf

1.2 MB

report.pdf

860 KB

100% private

Nothing is uploaded — everything runs in your browser.

Free forever

No account or payment required.

No sign-up

Open the tool and start using it right away.

Local processing

Processing time depends on your input and device.

About this tool

Pretty-print SQL across all 21 dialects the formatter implements, with keyword casing and indent width under your control. Refuses unterminated comments, unterminated strings and unbalanced parentheses rather than hand back SQL with different tokens than you pasted.

The SQL Formatter re-indents and re-cases a query you paste, across all 21 dialects the underlying formatter implements, and tells you plainly when it cannot read what you gave it. It parses CTEs, subqueries, JOIN chains, CASE expressions, window functions and INSERT ... SELECT without touching the contents of your string literals or comments.

The dialect selector matters more than any other setting here, because SQL is not one language. It decides whether \ escapes the next character inside a quoted string, whether $$ opens a dollar-quoted body, and whether [brackets] or backticks are identifiers. The page defaults to PostgreSQL, which accepts the widest range of pasted dialect, and it refuses rather than guess when a construct is ambiguous.

Everything happens in your browser. A query pulled from a log file, a customer record set or a production console routinely contains names worth keeping off a server, and nothing you type here is uploaded or sent anywhere.

Key features

Everything you get with SQL Formatter — no premium upsell.

All 21 dialects the formatter implements, from PostgreSQL and MySQL to DuckDB, Trino, ClickHouse and Oracle PL/SQL

Keyword casing set to UPPERCASE, lowercase, or left exactly as you wrote it

Indentation with 2 spaces, 4 spaces or a real tab character, plus 0, 1 or 2 blank lines between statements

Read the dialect before reading the SQL: backslash escapes, E-strings, dollar-quoted bodies, backtick and bracket identifiers are all recognised

Refuses what it would otherwise corrupt: unterminated comments and strings, unbalanced parentheses, and nested comments in dialects that do not nest them

Copy to the clipboard or download as a .sql file

Everything runs in your browser, so no query text is ever uploaded

How to use SQL Formatter

Follow the steps below to use the tool.

  1. 1

    Paste Your Query

    Put your minified, log-exported or ORM-generated SQL in the input box. Nothing is pre-filled, so what you see is only ever your own text.

  2. 2

    Choose the Dialect

    Pick the database your SQL is written for. This is not cosmetic: it decides how string escapes, quoted identifiers and dollar-quoted bodies are read. The default is PostgreSQL.

  3. 3

    Read the Result Panel

    The output updates as you type. A Formatted badge means the query parsed; Not formatted means the page refused it and said which cap or which construct stopped it, with a line and column where it has one.

  4. 4

    Copy or Download

    Take the formatted SQL from the clipboard, or download it as formatted.sql.

Still free, still private — your files never leave your device.

Launch SQL Formatter

Frequently asked questions

Quick answers before you launch the tool.