🗄️

SQL Formatter

Format & beautify SQL queries

Input SQL
Formatted

About SQL Formatter

ORM-generated SQL is unreadable. Query copied from a log is one long line. This tool adds proper indentation, keyword casing, and clause alignment so you can actually understand what a query is doing. Select the dialect (MySQL, PostgreSQL, SQLite, SQL Server) for better keyword handling. For most queries it makes no difference, but dialect-specific syntax is handled correctly. Runs entirely in the browser — no query content is sent anywhere. Useful for working with production schemas or sensitive data without sending it to a third-party service.

Common Use Cases

  • Reading SQL pulled from database logs or monitoring dashboards
  • Cleaning up ORM-generated queries when debugging N+1 problems
  • Preparing queries for documentation or code reviews
  • Making a colleague's undocumented 80-line query readable

Frequently Asked Questions

Which dialects are supported?+
Standard SQL, MySQL, PostgreSQL, SQLite, and T-SQL (SQL Server). Most queries format correctly regardless of dialect selection.
Does this validate SQL?+
It catches obvious structural issues, but it is not a full parser. For real validation, run the query against the database.
Will it change my query logic?+
No. Only whitespace, indentation, and keyword casing change. Clause order and query logic are untouched.
Is there a length limit?+
No — everything runs in the browser. Multi-hundred-line queries with CTEs and nested subqueries work fine.