SQL Formatter
Turn a long single-line query into properly indented SQL that shows its structure at a glance.
Your data stays on your device
Input — SQL
- characters
- 0
- lines
- 0
- size
- 0 B
Output — Formatted SQL
- characters
- 0
- lines
- 0
- size
- 0 B
Options
About this tool
Queries that come out of an ORM log or an application trace arrive as one enormous line. Understanding a five-way join in that form is close to impossible; formatting it reveals the structure immediately.
The formatter is dialect-aware, so PostgreSQL, MySQL, SQLite, BigQuery and several others are parsed with their own keyword sets and syntax quirks rather than a generic approximation.
How to use this tool
- Paste the SQL query you want to format.
- Select the dialect that matches your database.
- Choose keyword casing and indentation width.
- Press Format and copy the readable query.
Key features
- Dialect support for PostgreSQL, MySQL, MariaDB, SQLite, BigQuery, Db2 and more
- Keyword casing: uppercase, lowercase or preserved
- Configurable indent width
- Clause-aware line breaking for SELECT, FROM, WHERE, JOIN and GROUP BY
- Comments preserved in place
- Multiple statements formatted in one pass
Example
Input — SQL
select id,name from users where active=true order by nameOutput — SQL
SELECT
id,
name
FROM
users
WHERE
active = true
ORDER BY
nameGood to know
- Formatting is syntactic only. The query is never executed and is not checked for semantic validity.
- Vendor-specific extensions outside the selected dialect may not break onto lines ideally.
- Parameter placeholders are preserved verbatim, not substituted.
Frequently asked questions
Does the tool run my query?
No. There is no database connection of any kind. The text is parsed and re-printed in your browser.
Why choose a dialect?
Keyword sets and syntax differ. Selecting the right dialect means constructs like PostgreSQL casts or BigQuery array syntax are formatted correctly instead of being mangled.
Should keywords be uppercase?
It is the long-standing convention and makes the shape of a query easier to scan. Some teams prefer lowercase; the option exists either way.
Are my comments kept?
Yes. Both line and block comments are preserved at their original positions.
Your data stays on your device
Your data is processed locally in your browser and is not uploaded to our server. This page keeps working after you go offline, because there is nothing to send.