SQL Formatter
Paste a query and get it back with one clause per line and consistent indentation, for standard SQL, MySQL, MariaDB, PostgreSQL, SQLite or SQL Server. It only re-spaces the text in your browser: the query is never run and never uploaded.
Free, no sign-up. Your SQL stays in your browser and is never run.
Your SQL
Paste SQL and press Format.
How to
Format SQL in three steps
Paste your query
Drop in one statement or several. A query written on a single line is fine.
Pick the dialect
Choose the database you write for so its quoting, operators and keywords are read correctly.
Format, copy or download
Press Format, then copy the result or save it as a .sql file.
Good to know
- The dialect matters for quoting and operators: backticks for MySQL, double quotes and :: casts for PostgreSQL, square brackets for SQL Server.
- Formatting only changes spacing, letter case of keywords and line breaks. String contents, comments and identifiers are left as written.
- The tool does not run, validate or optimise your query. A query that formats cleanly can still be wrong for your schema.
- If the formatter reports a problem, check for an unclosed quote or a symbol that belongs to a different dialect.
FAQ
SQL formatter questions
Is my SQL uploaded or run?
Neither. The formatter runs in your browser, the page makes no network request with your query, and nothing connects to a database. Avoid pasting real passwords or personal data all the same.
Which databases are supported?
Standard SQL, MySQL, MariaDB, PostgreSQL, SQLite and SQL Server (T-SQL). Other dialects are not offered here; standard SQL works for many simple queries.
Does formatting change what the query does?
It changes only whitespace, line breaks and, if you choose, the letter case of keywords. Strings and comments are kept as written. Run the formatted query in a test environment before relying on it.
Why does it say my SQL could not be read?
The formatter found something it does not understand, often an unclosed quote or comment, or syntax from another dialect. Try another dialect, or check the part of the query named in the message.
Does it format stored procedures and long scripts?
Simple procedural blocks may format acceptably, but the formatter is built mainly for queries and statements. Check long scripts by eye. The limit is 300,000 characters.