SQL Formatter

Developer Tools

Beautify SQL queries with dialect support and customizable indentation.

Formatted SQL appears here

What is SQL Formatter?

SQL Formatter beautifies raw or minified SQL queries by adding proper indentation, capitalising keywords, and aligning clauses like SELECT, FROM, WHERE, and JOIN. It supports MySQL, PostgreSQL, SQLite, and T-SQL dialects.

How to use SQL Formatter

1

Choose your dialect

Select MySQL, PostgreSQL, SQLite, or T-SQL using the dialect buttons to apply the correct keyword set.

2

Paste your SQL

Paste a raw or one-line SQL query — however long or complex — into the input area.

3

Set indentation

Choose 2 or 4 spaces for indentation. Toggle "Uppercase keywords" to match your team's style guide.

4

Review the output

The formatted SQL appears on the right with coloured keywords, strings, and comments.

5

Copy or save

Click Copy to use the formatted query in your database client, or Download to save as a .sql file.

Who uses SQL Formatter?

Code reviews

Database administrators

Format queries submitted in pull requests to make them readable before reviewing logic, indexes, and joins.

Documentation

Technical writers

Beautify SQL examples in README files, wikis, and API docs so readers can follow the query structure at a glance.

Query debugging

Backend developers

Format a long, auto-generated ORM query into indented SQL to find performance bottlenecks and missing indexes.

Related Tools

FAQ

Which SQL dialects are supported?+
MySQL, PostgreSQL, SQLite, and Microsoft SQL Server (T-SQL) dialects are supported with dialect-specific keyword sets.
Can it handle complex queries with subqueries and CTEs?+
Yes. The formatter handles nested subqueries, CTEs (WITH clauses), JOINs, and window functions.
Does it format stored procedures?+
Basic stored procedure and function formatting is supported. For complex procedural code, results may vary.

More Tools

View all