SQL Formatter & Beautifier
Format and indent SQL queries into clean, readable syntax, live as you type, across multiple dialects.
Formats live as you type, entirely in your browser. Nothing you type is sent anywhere.
Need the opposite? SQL Minify
What is SQL Formatter & Beautifier?
Paste a compressed or messily-formatted SQL query and get it reformatted with consistent indentation and capitalized keywords, powered by the sql-formatter library. Supports standard SQL plus MySQL, PostgreSQL, SQLite, and MariaDB dialect quirks.
How to Use the SQL Formatter
- 1
Paste the SQL Query: Enter a compressed or messily-formatted query.
- 2
Choose a Dialect: Pick standard SQL, MySQL, PostgreSQL, SQLite, or MariaDB to match your database.
- 3
Read the Formatted Result Instantly: The indented, keyword-capitalized query appears automatically as you type.
- 4
Copy the Result: Use the copy button to copy the formatted query.
How It Works
The sql-formatter library tokenizes your query and re-prints it with consistent indentation and line breaks around major clauses (SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY, and similar), capitalizing keywords and putting each selected column or condition on its own indented line so the query's structure is readable at a glance.
Example
select id,name,email from users where active=1 and role='admin' order by name;SELECT
id,
name,
email
FROM
users
WHERE
active = 1
AND role = 'admin'
ORDER BY
name;Keywords capitalize, and each selected column and condition moves to its own indented line under its clause.
Common Use Cases
Turning a compressed query pulled from a slow-query log or an ORM's debug output into something reviewable in a pull request, or standardizing formatting style across a team that writes SQL by hand in migrations and reports.
Frequently Asked Questions
Common questions about SQL Formatter & Beautifier.