Skip to content
helpyself

SQL Formatter

Local only — nothing is uploaded unless you save or share it.

An SQL formatter for 21 dialects — paste unreadable SQL, get it laid out, nothing uploaded.

  1. Paste the SQL — an example is already there to show what it does
  2. Pick the dialect, the keyword case and the indent you use
  3. Copy the result, or download it as a .sql file

Share a link

Saves this to your files and gives you a web address anyone can open. It stops working on its own.

Link lasts
Save this tool

Keep SQL Formatter handy

Bookmark it

About this tool

SQL arrives unreadable more often than not. It comes out of an ORM as one 400-character line, out of a log with the newlines stripped, out of a colleague's editor with their tab settings, or out of a model that wrote it all on one row. You cannot review a query you cannot see the shape of — sql pretty print is not a nicety, it is how a query becomes reviewable — and reviewing queries is where the expensive mistakes get caught. This sql beautifier lays it out: keywords aligned, joins on their own lines, conditions indented under the clause they belong to. To format sql query text properly it has to know the dialect, so choose yours and it uses that database's rules — Postgres, MySQL, SQLite, T-SQL, Oracle, BigQuery, Snowflake, Redshift and thirteen more — because the same text is valid in one and meaningless in another. It happens in your browser. Queries are one of the more revealing things a person can paste into a website: table names, column names, the shape of the business, sometimes an email address in a WHERE clause. None of it is sent anywhere, and there is nothing on our side to store. One thing it does not do, said plainly: it formats, it does not validate. A query with a missing table or a typo'd column comes back neatly laid out, because tidying text is not the same as checking it against a database. If it comes out looking wrong, that is worth reading closely rather than dismissing — a formatter laying something out unexpectedly is often the first sign a query does not mean what it looks like it means.

Frequently asked questions

Does it check whether my query is valid?

No. It lays out the text it is given without connecting to anything, so a query naming a table that does not exist comes back beautifully formatted. Formatting and validating are different jobs and only one of them can be done without your database. That said, badly formatted output is worth a second look — it usually means the query does not parse the way you assumed.

Which dialects does it know?

Twenty-one, including PostgreSQL, MySQL, MariaDB, SQLite, T-SQL (SQL Server), PL/SQL (Oracle), BigQuery, Snowflake, Redshift, Spark, Hive, Trino, ClickHouse, DuckDB and DB2. Pick the one you are actually using — dialects disagree about quoting, about which words are reserved, and about what a bracket means, so choosing the right one is the difference between a good layout and a mangled one.

Is my query uploaded?

No. It runs in your browser and nothing is sent to us. That matters more with SQL than with most text: a query carries your table names, your column names and often a real identifier in a WHERE clause, which together describe your database to anybody who collects them.

Can I use it on several statements at once?

Yes. Paste a whole script and each statement is laid out in turn, with a blank line between them by default and up to five if you prefer more air. The count under the result tells you how many it found, which is a quick way to notice a stray semicolon inside a string.

Why are my keywords suddenly uppercase?

Because that is the default, and it is the convention most style guides use — capital keywords make the structure visible at a glance. Set it to lower or leave it alone with "preserve" if your team writes them differently. It is one of the settings that gets argued about most and costs nothing to change.

Is there an API?

Yes, and it works through MCP as well, so an assistant can format SQL without anybody copying anything between windows. Every sql formatter online asks you to paste; this one does not have to. Post the query with a dialect and get the formatted text back along with the statement count. It is one of the few tools here where the API is the more likely way in — SQL is usually being formatted by something rather than by somebody.

Can it minify SQL instead?

Not yet. Collapsing a query onto one line sounds like the same job backwards and is not — whitespace inside strings and comments has to survive, and getting that subtly wrong produces a query that runs and does something else. If you need it, say so on the contact page.

Help improve this tool

Found a bug, want a change, or need a tool we don't have?

/sql-formatter

↑↓ to move · Enter to open · Esc to close