SQL Formatter

Client-sideNo sign-upFree

Format SQL with a real parser - keyword casing, clause breaks, and dialect support.

Quick facts

Category
Formatters & Beautifiers
Best for
Making a dense one-line query reviewable in a PR
Input
✓ Formatted
Formatted output
SELECT u.id, u.name, o.total FROM users u JOIN orders o ON o.user_id = u.id WHERE o.total > 100 AND u.active = TRUE ORDER BY o.total DESC
12 lines
Formats SQL using the sql-formatter package - a purpose-built parser that understands SQL clause structure across several real dialects, rather than regex keyword-matching. Pick a dialect above to match the SQL flavor you're working with. Runs entirely client-side; nothing you paste is uploaded.
In-content slot
Was this tool helpful?
On this page

Overview

Paste a SQL statement and get it reformatted by the sql-formatter package - a purpose-built SQL parser and pretty-printer, not a regex keyword-matcher - so keywords are capitalized (SELECT, FROM, WHERE, JOIN, and friends normalized to uppercase) and each major clause breaks onto its own line with AND/OR conditions and comma-separated columns indented underneath. Because it parses SQL structure rather than pattern-matching on keywords, it handles nested subqueries, comments, and nuanced clause boundaries far more reliably than a hand-rolled formatter would. Pick a dialect - Standard SQL, MySQL, PostgreSQL, T-SQL, SQLite, or PL/SQL - to match dialect-specific syntax quirks. Runs entirely client-side; nothing you paste is uploaded.

Best for: Making a dense one-line query reviewable in a PR

How to use this tool

  1. Paste your SQL. A SELECT, INSERT, UPDATE, or DELETE statement, however it’s currently formatted.
  2. Pick a dialect. Standard SQL, MySQL, PostgreSQL, T-SQL, SQLite, or PL/SQL - each has its own parser rules.
  3. Parsed and reformatted. sql-formatter parses the query’s real structure and reprints it with consistent casing and indentation.
  4. Copy the readable result. Paste the formatted query into a PR, a code review, or documentation.

Why use this tool

Real SQL parsing, not regex

Built on the sql-formatter package, which parses clause structure instead of guessing from keyword patterns.

Consistent keyword casing

Every SELECT, FROM, and WHERE is capitalized the same way, regardless of how it was typed.

Handles nested queries and comments

Subqueries, joins, and inline comments are preserved and indented correctly, not just top-level clauses.

Multiple dialects supported

Switch between Standard SQL, MySQL, PostgreSQL, T-SQL, SQLite, and PL/SQL to match your database.

Frequently asked questions

It supports the dialects listed in the picker (Standard SQL, MySQL, PostgreSQL, T-SQL, SQLite, PL/SQL), each with its own parser rules from the underlying sql-formatter package. Other dialects the package supports (BigQuery, Snowflake, Redshift, and more) aren’t exposed in this picker, and highly vendor-specific extensions beyond what a given dialect’s parser recognizes may not format as expected.

A regex-based formatter can misfire on SQL embedded inside string literals, nested subqueries, or unusual clause ordering, because it has no real understanding of the query’s structure. A parser-based formatter builds an actual representation of the query first, so it reprints it correctly even for cases that would trip up simple keyword replacement.

No - this only formats SQL text. It never executes a query, never opens a database connection, and never sends anything you paste to a server; formatting happens entirely in your browser.

Explore more free tools

Formatters, converters, validators, and generators - all free and running entirely in your browser.

Browse more tools