SQL Formatter
Turn a long or messy SQL query into neat, indented SQL, with keywords in the case you like. For MySQL, PostgreSQL, SQL Server, Oracle, SQLite, BigQuery and more, right in your browser.
The formatted SQL shows here as you type or paste.
How to use it
- 1Paste your SQL, or open a .sql file.
- 2Pick your database's dialect, how keywords are written (UPPERCASE, lowercase or as typed) and the indent.
- 3The formatted SQL appears as you type. If part of it can't be read, the line and column are shown.
- 4Copy it, or download it as a .sql file.
Frequently asked questions
Is it safe to paste my company's SQL here?
Yes. The SQL is formatted by your browser, on your device. Nothing you paste or open is sent anywhere or saved, so the table names and data in your queries stay private.
Which databases does it support?
Standard SQL, MySQL, MariaDB, PostgreSQL, SQL Server (T-SQL), Oracle PL/SQL, SQLite, BigQuery, Snowflake, Redshift, Spark, Db2, Hive, Trino, DuckDB, ClickHouse and more. Pick yours, so that its own keywords, quotes and comments are understood.
Does formatting change what my query does?
No. Only spaces, line breaks and, if you choose, the case of keywords change. Table and column names, text in quotes, numbers and comments stay exactly as you wrote them.
Why does it say something is wrong in my SQL?
Usually a quote mark or bracket that is never closed, or syntax that belongs to another database. Check the line shown, and pick your database's dialect.
Is there a size limit?
Up to 500,000 characters at a time, which is thousands of lines, with brackets nested up to 100 deep.
Related tools
- JSON Formatter and ValidatorFormat, minify and validate JSON, with any mistake shown by its line and column.
- Base64 Decode and EncodeDecode or encode Base64 text and files, with Hindi and emoji kept intact.
- JWT DecoderDecode a JSON Web Token, read its claims and expiry, and verify its signature.
- Regex TesterTest JavaScript regular expressions live, with every match and group highlighted.