How to use Pretty SQL
- 1. Paste SQL. Drop a .sql file or paste a one-line query from your ORM.
- 2. Pick dialect. Choose PostgreSQL for jsonb, RETURNING, and ILIKE-friendly spacing — or MySQL / SQLite when that matches your engine.
- 3. Copy formatted SQL. Use the output pane for docs, code review, or Slack snippets.
About this tool
“Pretty sql” and “sql pretty” are formatting intents, not dialect lectures. Developers paste opaque SQL and want whitespace and keyword case fixed fast. This alias matches those queries with an H1 that says pretty-print — and it calls out PostgreSQL because that is what many searchers run.
Pretty print vs minify
Pretty-printing adds line breaks and indentation for humans. Minifying removes them for wire size. This tool is for reading and reviewing — not shrinking queries sent to production.
PostgreSQL beautifier example
Select the PostgreSQL dialect, paste a one-liner with joins and jsonb, and copy the indented result. Identifiers, `::` casts, and `RETURNING` stay readable instead of wrapping oddly under a MySQL preset.
Dialect matters
The same SELECT can format differently under PostgreSQL vs MySQL rules. Pick the dialect that matches your database so backticks, square brackets, and function names stay sensible.
Code examples
Postgres EXPLAIN
EXPLAIN ANALYZE
SELECT u.email, COUNT(*)
FROM users u
JOIN orders o ON o.user_id = u.id
GROUP BY u.email;Node
import { format } from "sql-formatter";
format(sql, { language: "postgresql" });Parameterized
SELECT * FROM users WHERE email = $1; -- Postgres
SELECT * FROM users WHERE email = ?; -- MySQL / SQLite