130 of 149 tools live Roadmap LatestImage to Text

SQL Formatter

Turn a one-line query into readable SQL, or squeeze it back to one line.

Works in your browser. Your SQL is never sent to us or run.

Formatted in your browser. Your SQL is never sent to us or run against any database.

SQL Formatter at a glance

Price
Free
Data sent to us
None, it runs in your browser
Sign-up
Not needed
Dialects
13, including MySQL, PostgreSQL, SQL Server, Oracle, SQLite, BigQuery
Modes
Formatted, minified
Runs queries
Never

How to use SQL Formatter

Takes about 1 minute. You need a SQL query or script.

  1. Paste your SQLPut the query in the left box. The formatted version appears on the right.
  2. Pick the dialect and styleChoose your database, keyword case, indent and layout.
  3. Copy or downloadCopy the result, switch to Minified for one line, or download a .sql file.
SQL Formatter: Turn a one-line query into readable SQL, or squeeze it back to one line.

Paste a query or a script and get readable SQL as you type: each clause on its own line, columns and conditions indented, joins lined up, keywords in upper or lower case. Choose the dialect, from standard SQL, MySQL, MariaDB, PostgreSQL, SQLite, SQL Server and Oracle to BigQuery, Snowflake, Redshift, Spark, DB2 and DuckDB, the indent and the layout. Switch to Minified for one compact line without comments. Quoted text is never changed, and errors point to where the problem starts.

How it works

SQL Formatter is a web page that does its work on your own device. Everything you type or choose is worked out by your browser and never sent to a server, so nothing is stored and there is nothing to delete. There is no account, no sign-up and no limit on how often you use it.

Straight to one job

Readable SQL in one paste

Queries copied from logs, ORMs, dashboards and chat arrive as one long line. Paste one, or a whole script of several separated by semicolons, and it comes back laid out the way people write SQL by hand: each clause on its own line, columns and conditions indented under it, joins lined up, and keywords in capitals or lower case as you prefer. Pick the dialect you use, from MySQL, PostgreSQL, SQLite, SQL Server and Oracle to BigQuery, Snowflake, Redshift, Spark and DuckDB, so its own syntax, such as square-bracket names in SQL Server or backticks in MySQL, is understood.

Format or minify

Formatted output is for reading, reviewing and pasting into a pull request; choose 2 or 4 spaces or tabs, and a standard layout or one with the keywords in a column. Minified output removes comments and extra spaces and puts the whole query on one line, for a config file, a log line or a URL. Text inside quotes, quoted identifiers and the meaning of the query are never changed, and the query is never run.

When it will not format

If a query does not read as the chosen dialect, it is formatted as standard SQL and the page suggests checking the dialect. If it cannot be read at all, usually because of a missing quote or bracket, the page says where the problem starts and leaves your SQL as it was.

What this tool does not do

  • It does not run queries or connect to a database.
  • It does not check that tables or columns exist, or optimise a query.
  • It does not convert one dialect into another.

What it does

  • Beautify SQL as you type, or minify it to one line
  • Thirteen dialects, from MySQL and PostgreSQL to BigQuery and Snowflake
  • Keywords upper case, lower case or as typed
  • 2 or 4 spaces or tabs; standard or column layout
  • Several queries at once, separated by semicolons
  • Copy or download as a .sql file
  • No upload, no account, no sign-up

Questions

How do I format SQL?

Paste it into the left box. It is laid out as you type, with each clause on its own line and the rest indented. Choose your database's dialect for the best result.

Which databases does it support?

Standard SQL, MySQL, MariaDB, PostgreSQL, SQLite, SQL Server (T-SQL), Oracle (PL/SQL), BigQuery, Snowflake, Redshift, Spark SQL, DB2 and DuckDB.

Can I minify SQL?

Yes. Choose Minified to remove comments, line breaks and extra spaces, leaving one line. Quoted strings and identifiers are kept exactly.

Will formatting change what my query does?

No. Only spacing, line breaks and keyword case change. Text in quotes and names are left as they are.

Why does it say it formatted as standard SQL?

The query used syntax the chosen dialect does not accept, such as square brackets with MySQL selected. Pick the right dialect and it formats in that dialect's style.

Is my SQL sent anywhere or run?

No. It is formatted in your browser and never sent to us or run against a database, which matters for queries with table names or data in them.

Is it free?

Yes, completely free, with no sign-up.

More

Privacy policy · Support · Changelog

Suggest a tool

Tell us what the tool should do. If we build it, we will let you know.

Used only to reply to you. See our Privacy Policy.