SQL Formatter
Turn long, one-line SQL into readable, properly indented queries, or minify it back into one line. Choose your database dialect for correct handling of its syntax.
Free · No sign-up · Files stay on your device
How to use SQL Formatter
- 1Paste your SQL.
- 2Choose the dialect, keyword case and indentation.
- 3Copy or download the formatted query.
Features
- MySQL, PostgreSQL, SQL Server, SQLite, Oracle, BigQuery…
- Uppercase or lowercase keywords
- 2 or 4 spaces or tabs
- Minify to one line
- Clear error messages
Why format SQL?
Well-formatted SQL puts each clause (SELECT, FROM, JOIN, WHERE, GROUP BY) on its own line and indents nested queries, which makes complex queries much easier to review, debug and keep in version control.
Frequently asked questions
Is my SQL sent anywhere?
No. Formatting runs in your browser, so queries with sensitive data stay private.
Does it check that my query is valid?
It reports syntax it cannot parse, but it does not run the query against a database.
Can it format multiple statements?
Yes. Statements separated by semicolons are formatted one after another.
Related tools
JSON FormatterFormat, beautify, validate and minify JSON online for free. Find syntax errors with exact line numbers. Runs in your browser, your data is never uploaded.XML FormatterFormat, beautify, validate and minify XML online for free. Get clear error messages for invalid XML. Works with sitemaps, RSS feeds, SVG and config files.JavaScript FormatterFormat and beautify JavaScript code online for free. Make minified scripts, JSON-like objects and messy JavaScript readable with clean indentation.