SQL Formatter

Format, indent and beautify SQL queries online. Supports SELECT, JOIN, WHERE, GROUP BY, keyword case conversion and minify mode. 100% client-side — no data uploaded.

Did we solve your problem today?

What is a SQL Formatter?

A SQL formatter (also called a SQL beautifier or pretty printer) takes a raw or minified SQL query and re-indents it with consistent spacing and line breaks — making it significantly easier to read, review and debug.

How to Use This Tool

  1. Paste your SQL query into the SQL Input panel.
  2. Choose your preferred keyword case (UPPERCASE is the SQL convention), dialect and indent size.
  3. Click Format SQL or press Ctrl + Enter.
  4. Copy the result with the Copy button.

Use Minify to collapse a formatted query back to a single line — useful for embedding SQL in application code or config files.

What Gets Formatted

ElementBehaviour
SELECT, FROM, WHERE …Each clause starts on a new line
AND, ORIndented on their own line within WHERE / HAVING
JOIN, LEFT JOIN, INNER JOIN …Each join starts on a new line
ONIndented below the JOIN it belongs to
GROUP BY, ORDER BYEach on a new line
LIMIT, OFFSET, HAVINGEach on a new line

Keyword Case Options

SQL Dialects

Choosing the right dialect ensures that database-specific keywords are formatted and cased correctly rather than treated as identifiers.

Indent Size

Two-space indentation is compact and common in front-end codebases. Four-space indentation (the default in most SQL editors) provides greater visual separation between nested clauses and subqueries. Both produce identical query logic — the choice is purely stylistic.

When to Use Minify

Minified SQL (collapsed to a single line) is useful when:

The minifier removes all unnecessary whitespace and newlines while preserving string literals and comments unchanged.

Privacy

This tool runs entirely in your browser. No SQL is ever sent to a server, stored in cookies, or logged anywhere.

FAQ

Is my SQL code uploaded to a server?

No. All formatting runs locally in your browser using JavaScript. Your SQL query never leaves your device.

Which SQL dialects are supported?

Standard SQL, MySQL and PostgreSQL. For most SELECT, INSERT, UPDATE and DELETE queries the formatting is identical across dialects. Dialect selection mainly affects future comment-syntax handling.

What does keyword case conversion do?

SQL keywords like SELECT, FROM, WHERE can be written in any case. UPPERCASE is the most common SQL convention and improves readability by making the structure of the query visually distinct from table and column names.

What is SQL Minify?

Minify collapses your SQL to a single line with minimal whitespace. This is useful when embedding queries in code, config files, or URLs where newlines and indentation are unwanted.

Are complex expressions like BETWEEN...AND handled correctly?

The formatter uses a keyword-based approach without a full parser. Simple BETWEEN x AND y expressions may have the AND placed on an indented line. For production use, review the output — the formatter is best suited for improving readability of straightforward queries.