Home › Free tools › SQL formatter
Free developer tool · MySQL, PostgreSQL, SQLite, SQL Server

SQL formatter – beautify messy queries in one click

Paste a long one-line SQL query and get it neatly indented, with each clause on its own line, uppercase keywords and aligned JOINs and conditions. Minify it back to one line when you need to.

Beautify or minifyUPPER or lower keywordsComments and strings kept

Why format SQL?

Queries copied from logs, ORMs or reports often arrive as one long line. Formatting puts each clause – SELECT, FROM, JOIN, WHERE, GROUP BY, ORDER BY – on its own line and indents the details, so you can read the logic, spot a missing join condition and review changes much faster.

SQL style tips

  • Write keywords in UPPERCASE and table and column names in lowercase – it makes queries easy to scan.
  • Put each selected column on its own line so diffs in code review are small.
  • Use short, meaningful table aliases (users u, orders o) and always prefix columns in joins.
  • Put every JOIN condition after ON, and filters in WHERE.
  • Avoid SELECT * in production code – list the columns you need.

Which databases are supported?

The formatter works with standard SQL used by MySQL, MariaDB, PostgreSQL, SQLite, SQL Server and Oracle. Strings, quoted identifiers, backticks, square brackets and comments are kept exactly as typed. It formats the text only – it does not run or validate the query against a database.

Frequently asked questions

How do I format a SQL query?

Paste the query and click Format. Each clause moves to its own line, columns are listed one per line and keywords are capitalised.

Does the formatter change my query?

Only whitespace and, if you choose, the case of SQL keywords. Strings, identifiers, numbers and comments are kept exactly as they are.

Can I minify SQL?

Yes. Click Minify to remove line breaks, extra spaces and line comments, which is handy for embedding a query in code or a URL.

Does it work with MySQL and PostgreSQL?

Yes. It understands common syntax from MySQL, PostgreSQL, SQLite, SQL Server and Oracle, including backtick and bracket-quoted names.

Is my SQL sent to a server?

No. Formatting runs entirely in your browser.

Need a website or app built?

We design and build websites and Android apps for clients worldwide – clear scope, fixed price, fast delivery.

Techpass Master Technologies · Websites, Android apps and digital marketing

WhatsApp us📞 Call now