🗃️

SQL Formatter

Paste a messy SQL query and get clean, indented output. Plus a minify mode for embedding in code.

SQL input

0 chars

Formatted

Formatted SQL will appear here…

Minified (single line)

Single-line output will appear here…

About this tool

A fast SQL formatter that handles SELECT, INSERT, UPDATE, DELETE, JOINs, subqueries, and CTEs. Splits keywords onto their own lines and indents inner expressions for instant readability. Switch keyword case and indent depth on the fly.

Pretty-print SELECT, INSERT, UPDATE, DELETE
🪜Smart indentation per clause
🔠Toggle UPPERCASE keywords
📏2 / 4 / 8 space indent presets
Single-line minify for embedding
🔒Runs in browser — no data leaves

How to use it

Quick steps to get the most out of this utility.

  1. 1

    Paste your SQL

    Drop a query of any size — multi-line or single-line both work.

  2. 2

    Pick indent and case

    Choose 2 / 4 / 8 spaces. Toggle uppercase keywords if your style guide demands it.

  3. 3

    Copy formatted output

    Use it in pull requests, ticket comments, or your code editor.

  4. 4

    Or grab the minified version

    For embedding in app code, ORM raw queries, or compact log lines.

Why formatted SQL matters

SQL is one of the few languages where the same logic can be written as a 200-character one-liner or a 30-line vertical layout — both syntactically correct, but only one of them is actually reviewable in a pull request. When clauses live on their own line, you can scan filter logic, join conditions, and projected columns independently rather than parsing one wall of text.

Conventions worth standardizing

  • Top-level keywords on their own line: SELECT, FROM, WHERE, GROUP BY, ORDER BY, LIMIT.
  • One column per line in projections of more than 2–3 columns.
  • JOINs aligned with FROM, ON conditions indented under them.
  • Boolean operators leading in multi-line WHERE clauses (AND/OR at the start, not the end).

Frequently asked questions

Which SQL dialects does this support?+

It handles standard ANSI SQL keywords plus common PostgreSQL, MySQL, and SQL Server syntax. Stored procedures, vendor-specific functions, and CTE-heavy queries usually format cleanly but may need manual tweaks for edge cases.

Should keywords be uppercase?+

It's a style choice. Uppercase keywords (SELECT, WHERE, JOIN) are the traditional convention and easier to scan in mixed-case codebases. Lowercase is increasingly common in modern style guides — pick one and apply it consistently.

Why do I need a formatter — won't my IDE do it?+

Most IDEs do, but you frequently get SQL from logs, ORM-generated output, ticket comments, or screenshots. A web formatter is the fastest way to make a one-line query readable enough to debug.

Is the SQL sent anywhere?+

No. Everything runs in your browser. You can paste production-shaped queries (after sanitizing real data) without privacy concerns.

Keep exploring

More utilities and reading from Toolisk.