SQL formatter
Paste a query or open a .sql file. Pick the database, how you want the keywords written, and the indent. Format SQL rewrites the statement with a line for each clause.
- Indent and keywords
- Free, no sign-up
Runs in your browser. Nothing you type or open is uploaded. Free to use, no account. More code and data tools
How to use it
- Paste the SQL or open a .sql file.
- Pick the database, the keyword style and the indent.
- Press Format SQL, then copy or download the result.
How a statement is laid out
The formatter knows the keywords of each database, so SELECT, FROM and WHERE land on their own lines and the lists under them line up. Uppercase, lowercase or the casing you typed are all available.
A missing parenthesis or a stray comma is reported, and the first box stays as you typed it. The page formats one script at a time. Running the query stays with your database.
Private by design
Privacy
Everything runs in this page and stays on your device. The statement is kept in this tab, so a reload brings it back, and closing the tab clears it.
This page also shows Google ads, which can use cookies. Privacy and cookies explains how.
Questions
Which databases are listed?
Standard SQL, PostgreSQL, MySQL, MariaDB, SQLite, SQL Server, Oracle PL/SQL, BigQuery, Snowflake, Redshift, Spark, Hive, DuckDB, ClickHouse, Trino, DB2, N1QL, TiDB and SingleStore.
Will it fix a broken query?
It reports the problem it finds. It leaves the repair to you, in the first box.
Can I keep my keyword casing?
Yes. Choose Leave as typed.
Does it run the query?
The page lays the statement out. Your database stays uncontacted.