Free Online SQL Formatter
Use this tool to format messy SQL queries into clean, readable code. Standardize your database scripts instantly.
Uppercase keywords (SELECT, FROM) and newlines improve readability.
Use this tool to format messy SQL queries into clean, readable code. Standardize your database scripts instantly.
Automatically capitalizes standard SQL keywords (SELECT, WHERE, JOIN) while keeping table names intact.
Aligns columns and conditions perfectly. Makes long, complex queries easy to scan.
Works with MySQL, PostgreSQL, SQL Server, and SQLite syntax dialects.
Structured Query Language (SQL) is powerful but messy. One-line snippets from log files or ORMs are impossible to debug. Our formatter fixes that.
Paste formatted queries into Pull Requests so your team understands what the migration does.
Take that 500-character error log line and turn it into a structured query you can analyze.
SQL keywords (`SELECT`, `FROM`, `WHERE`) are case-insensitive in most engines, but convention dictacts they be uppercase to distinguish them from table and column names. Our tool enforces this automatically.
Complex queries with nested `JOIN`s or subqueries are indented to visually separate logical blocks. We use standard 2-space or 4-space indentation equivalent to improve scanability.
The formatter is designed to be "dialect agnostic," meaning it works well with standard ANSI SQL as well as T-SQL, PL/pgSQL, and MySQL variants, focusing on shared syntax structures.
Copy your raw SQL query into the text box.
The tool immediately tokenizes your query and applies standard formatting rules.
Copy the clean SQL and run it in your database console with confidence.