Tools Pricing Roadmap Blog About Get Pro
// free online tool

SQL Formatter & Beautifier

Paste messy SQL and get clean, readable, properly indented queries instantly. Supports PostgreSQL, MySQL, SQLite and BigQuery dialects.

Offline-first PostgreSQL MySQL SQLite Syntax highlight Free forever
input 0 lines
↓ drop to load

// drag a file here to load it

formatted output
// formatted SQL appears here
Free plan: 25KB input limit Upgrade for 500KB →
Paste SQL above and click Format

Need to format SQL in your pipeline?

Free plan supports 25KB. Upgrade to Pro for 500KB input and higher limits across all tools.

Get Pro →

Instant formatting

Paste minified or messy SQL and get properly indented, readable output in milliseconds. Works on queries of any size.

🎨 Syntax highlighting

Keywords, functions, strings, and operators are color-coded so you can scan your query structure at a glance.

🗃 Multi-dialect support

Handles PostgreSQL, MySQL, SQLite, and BigQuery syntax including dialect-specific keywords and functions.

📦 Minify SQL

Strip all whitespace and comments to produce compact SQL for embedding in code or API requests.

🔒 100% private

Your queries never leave your browser. Safe to use with real table names, column names, and production queries.

No login needed

Just paste and format. No account, no signup, no email required. Free forever.

How to use the SQL Formatter

Why SQL formatting matters

Unformatted SQL is one of the hardest types of code to read. A single-line query that joins five tables with a dozen conditions is nearly impossible to debug or review. Formatted SQL with consistent keyword casing, aligned clauses, and proper indentation makes the query's structure immediately visible — what's being selected, which tables are joined, and what conditions filter the results.

SQL formatting conventions

The most common convention is uppercase for SQL keywords (SELECT, FROM, WHERE, JOIN) and lowercase for identifiers and column names. Each major clause starts on a new line. Subqueries are indented relative to their parent query. Long WHERE clauses break conditions onto separate lines with AND and OR at the start of each line for easy commenting.

Common SQL query patterns

A basic SELECT with WHERE: SELECT id, name FROM users WHERE active = 1. A JOIN: SELECT u.name, o.total FROM users u JOIN orders o ON u.id = o.user_id. Aggregation: SELECT department, COUNT(*) FROM employees GROUP BY department HAVING COUNT(*) > 5. A CTE: WITH ranked AS (SELECT *, ROW_NUMBER() OVER (PARTITION BY dept ORDER BY salary DESC) AS rn FROM employees) SELECT * FROM ranked WHERE rn = 1.

SQL dialects and compatibility

SQL formatting applies across all major databases — PostgreSQL, MySQL, SQLite, SQL Server, and Oracle — but syntax varies between them. PostgreSQL uses double quotes for identifiers and single quotes for strings. MySQL uses backticks for identifiers. SQL Server uses square brackets. Functions like IFNULL (MySQL), COALESCE (standard), and ISNULL (SQL Server) serve the same purpose but differ by dialect. Always test formatted queries in your target database.