SQL Formatter

Paste a messy, single-line SQL query and get back clean, indented SQL with proper keyword casing and line breaks. Pick from 14 dialects, including MySQL, PostgreSQL, SQLite, BigQuery, Snowflake, and Transact-SQL, so dialect-specific syntax is handled correctly. Formatting runs entirely in your browser using the sql-formatter library.

PrivateFreeWorks offline

Reviewed by Vincenzo Manto, Founder & Lead Developer · Last updated September 27, 2026

How it works

  1. 1

    Paste your SQL query or drop a .sql file into the input box.

  2. 2

    Choose the SQL dialect that matches your database.

  3. 3

    Pick a keyword case (UPPERCASE, lowercase, or preserve as-is).

  4. 4

    The formatted query appears instantly. Copy it or download it as a .sql file.

Readable SQL for code review and debugging

Long, single-line SQL queries generated by ORMs, logging tools, or copy-pasted from a database console are hard to read and harder to review in a pull request. This formatter breaks queries into properly indented clauses, with SELECT columns each on their own line and JOIN and WHERE conditions clearly separated, so you can understand what a query does at a glance.

Dialect-aware formatting for real-world databases

SQL isn't one language - every database vendor extends the standard with its own syntax. This tool exposes 14 dialects so you can format T-SQL stored procedures, BigQuery analytics queries, or PostgreSQL migrations correctly, without the formatter choking on syntax that's valid in one database but not another.

Why 14 dialects instead of just 'SQL'

A generic SQL beautifier that only knows the ANSI standard will mis-indent or reject PostgreSQL's ::type casts, BigQuery's backtick identifiers, and T-SQL's square-bracket names - the exact syntax real production queries use. Picking your actual dialect here avoids that class of false errors.

Frequently asked questions

Does this tool send my SQL to a server?

No. Formatting runs with the sql-formatter JavaScript library entirely inside your browser tab, and your queries are never uploaded.

Which SQL dialects are supported?

Standard SQL, MySQL, MariaDB, PostgreSQL, SQLite, BigQuery, IBM DB2, Hive, N1QL, PL/SQL, Redshift, Snowflake, Spark SQL, Transact-SQL, and Trino. Pick whichever matches your database for the most accurate formatting.

Why does the dialect matter for formatting?

Different databases have dialect-specific syntax, like PostgreSQL's ::type casts, BigQuery's backtick-quoted identifiers, or T-SQL's square-bracket identifiers, and picking the right dialect ensures those constructs are parsed and formatted correctly instead of breaking the output.

Can I control how keywords like SELECT and WHERE are cased?

Yes, use the Keywords selector to force UPPERCASE, force lowercase, or leave the casing exactly as you typed it.

What happens if my SQL has a syntax error?

The formatter will surface an error message describing what it couldn't parse, so you can fix the query before formatting it.

Related tools