Skip to content
ErgaLab
SQL

SQL Beautifier

Reformat dense or minified SQL with your choice of indent width and keyword casing — useful for matching your team's style guide.

Paste your SQL

Beautified output

SELECT p.name,
  p.price,
  c.name AS category
FROM products p
JOIN categories c ON p.category_id = c.id
WHERE p.price > 20
  AND p.in_stock = true
ORDER BY p.price DESC

How it works

This is the same clause-aware re-indenting engine as the SQL Formatter, with two style controls exposed: indent size (2 or 4 spaces) and keyword casing (UPPERCASE or lowercase). Use whichever matches your team's conventions.

As with the formatter, this reflows structure rather than validating correctness — it won't catch a typo in a column name, only make the query easier to read.

Examples

4-space, lowercase style

A common alternate house style.

select id,
    name
from users
where active = true

2-space, UPPERCASE style (default)

The most common convention.

SELECT id,
  name
FROM users
WHERE active = true

Frequently asked questions