Format SQL Queries

Turn a query copied from a log, an ORM or a colleague's one-liner into readable SQL with each clause on its own line. Pick your database's dialect so its syntax is understood.

  • Free
  • Runs in your browser
  • 14 SQL dialects
  • No sign-up
How it works

How It Works

Format SQL in three steps.

01

Pick the dialect

PostgreSQL, MySQL, SQL Server, BigQuery and others each have their own syntax.

02

Paste the query

One query or several separated by semicolons.

03

Copy the result

Formatted as you type, with your choice of keyword case and indent.

About

What does a SQL formatter change?

Only whitespace and, if you choose, the case of keywords. Each major clause (SELECT, FROM, JOIN, WHERE, GROUP BY, ORDER BY) starts on its own line, column lists and conditions are indented, and subqueries are nested one level deeper. The query means exactly the same thing afterwards; it is just readable in a code review, a ticket or your editor. Formatting uses the open-source sql-formatter library.

If a query uses syntax the chosen dialect does not know, such as T-SQL square brackets under Standard SQL, formatting stops with an error. Switch to the right dialect and try again.

14 dialects

Standard SQL, PostgreSQL, MySQL, MariaDB, SQLite, SQL Server, Oracle PL/SQL, BigQuery, Snowflake, Redshift, Spark, DuckDB, ClickHouse and Trino.

Keyword case

Upper-case keywords, lower-case, or leave them as typed.

Indent

2 spaces, 4 spaces or tabs.

Several statements

Statements separated by semicolons are formatted one after another with a blank line between them.

Features

Why Use This SQL Formatter

Readable SQL without an IDE.

Dialect-aware

Understands each database's quoting, functions and operators.

Formats as you type

No button to press; the result follows your input.

Queries stay private

Table names and data in your query are formatted in your browser and never uploaded.

One-click copy

Paste straight back into your editor or ticket.

✓ No Registration✓ Free✓ Browser-based✓ Text Stays Local
FAQ

Frequently Asked Questions

Questions people ask about the SQL Formatter.

No. Only spaces, line breaks and, optionally, keyword case change. String values and identifiers are left exactly as written.