SQL formatter
Format SQL queries with consistent indentation and keyword case for your dialect.
Runs in your browser. Your input is not uploaded.
What it does
The formatter puts each clause (SELECT, FROM, WHERE, JOIN) on its own line, indents column lists and sub-queries, and applies a consistent keyword case. It uses the sql-formatter library, which understands the syntax of each dialect listed.
How to use it
- Paste one or more SQL statements.
- Choose the dialect, keyword case and indent.
- Copy the formatted SQL.
Example
Input
select id,name from users where active=1 order by name
Output
SELECT id, name FROM users WHERE active = 1 ORDER BY name
Things to watch for
- Formatting does not check that the query is valid or will run.
- Template placeholders such as
{{table}}or${id}may confuse the parser. Replace them with names first.
Questions
- Which dialects are supported?
- Standard SQL, PostgreSQL, MySQL, MariaDB, SQLite, SQL Server (T-SQL), Oracle PL/SQL, BigQuery, Snowflake, Redshift and Spark.
- Why does it fail on my query?
- Usually the dialect is wrong (for example backtick identifiers in PostgreSQL mode) or the query contains template syntax.
- Can I keep keywords lower case?
- Yes. Choose Preserve or Lower for keyword case.
- Is my query sent anywhere?
- No. Formatting runs in this page.