SQL Formatter Free
Format cramped, single-line SQL into readable statements with line breaks and indentation. Works with MySQL, PostgreSQL, Oracle and more.
About this tool
Database type defaults to Auto, which detects the dialect from the syntax. You can also choose Standard SQL, MySQL, MariaDB, PostgreSQL, SQLite, SQL Server, BigQuery, or Oracle directly.
This only formats the SQL; it never runs it.
This tool runs entirely in your browser. Nothing you enter is sent to our server.
When to use it
Useful for taking SQL that's been squeezed onto one line, in a log or in code, and turning it into something where you can see what each clause does.
Also useful for making SQL in a code review or a document follow a consistent style of indentation and keyword casing.
How to use
- Paste your SQL into the input box.
- Choose indentation and whether keywords like SELECT are uppercase, lowercase, or left as entered, then click "Format". Database type can stay on "Auto", which detects it from the syntax.
- Copy the formatted result. Changing a setting reformats the text already shown.
About the database type
Different databases quote identifiers and use symbols differently. For example, MySQL uses backticks for names, SQL Server uses square brackets, and PostgreSQL uses :: for type casts. These dialect-specific details only parse correctly when the matching type is selected.
Auto tries Standard SQL and several other dialects in turn and uses the first one that parses successfully, showing which one it picked next to the button. If the result looks wrong, try selecting your database directly.
FAQ
- Why does it say "could not format this"?
- This usually means something in the SQL can't be parsed, such as an unclosed bracket or quote. Check the reported line and position; switching the database type sometimes resolves it too.
- Does this run the SQL against a database?
- No. It only rearranges the text and never connects to a database. Your SQL stays in your browser and is never sent anywhere.