How to use it
- 1Paste a query, open a .sql file or load the example.
- 2Choose the SQL dialect, indentation and keyword case.
- 3Review the formatted, highlighted output on the right.
- 4Copy the result or download it as a .sql file.
Readable SQL in one click
Long queries written on a single line are hard to review. The formatter places each clause (SELECT, FROM, JOIN, WHERE, GROUP BY…) on its own line, indents nested expressions and subqueries, and applies a consistent keyword case.
The open-source sql-formatter library provides formatting rules for standard SQL, MySQL, PostgreSQL, SQLite and SQL Server (T-SQL).
Formatting and syntax validation
Formatting changes the presentation of the text. A formatted result does not guarantee that the query is syntactically valid or that a database can run it. Formatting takes place in your browser without executing SQL or connecting to a database.
Frequently asked questions
Why does formatting fail on my query?
The query may use syntax specific to another dialect, or contain unclosed quotes or parentheses. Try selecting the matching dialect.
Does a formatted result mean my query is valid?
No. The tool provides a text layout. Syntax and behavior depend on the target database and dialect.
Can it format several statements?
Yes. Statements separated by semicolons are formatted one after another.