✏️ SQL Input376 chars
✨ Formatted SQL
SELECT u.id , u.name , u.email , o.order_id , o.total , p.product_name FROM users u INNER JOIN orders o ON u.id = o.user_id LEFT JOIN order_items oi ON o.order_id = oi.order_id LEFT JOIN products p ON oi.product_id = p.id WHERE u.active = 1 AND o.created_at >= '2024-01-01' AND o.total > 100 GROUP BY u.id , u.name , o.order_id HAVING COUNT ( oi.id )> 2 ORDER BY o.total desc LIMIT 50;

What is SQL Formatter?

An SQL formatter takes raw, unindented, or minified SQL queries and reformats them into clean, consistently styled code that is easy to read and maintain. Whether you have copied a query from a log file, exported it from an ORM, or inherited a sprawling stored procedure, reformatting makes the logic immediately clear.

This tool supports multiple SQL dialects including MySQL, PostgreSQL, SQLite, Microsoft SQL Server, and standard ANSI SQL. You can configure indentation width, keyword casing (uppercase, lowercase, or title case), and whether each clause starts on a new line. The minify option does the reverse — it strips all whitespace and newlines to produce the most compact form possible, useful for embedding queries in config files or reducing payload size.

Syntax highlighting colour-codes keywords, string literals, numbers, comments, and identifiers, making it easy to spot mistakes like unclosed quotes or missing commas at a glance. Well-formatted SQL is not just aesthetically pleasing — it reduces the chance of logic errors, makes peer review faster, and helps onboard new team members who need to understand complex joins, subqueries, and window functions quickly.

How to Use SQL Formatter

  1. Paste your SQL

    Paste any SQL query — no matter how messy or minified — into the editor area.

  2. Configure style options

    Choose your dialect, keyword case, indentation size, and whether to format or minify.

  3. Review with highlighting

    Syntax highlighting colours keywords, literals, and identifiers so you can review the query at a glance.

  4. Copy or download

    Copy the formatted query to your clipboard or download it as a .sql file.

Key Benefits

Multi-dialect support

Format queries for MySQL, PostgreSQL, SQLite, SQL Server, and ANSI SQL with dialect-specific rules.

Syntax highlighting

Colour-coded keywords, strings, and identifiers make complex queries far easier to read and debug.

Format or minify

Expand minified queries for readability or compress formatted queries for production use with one click.

No data leaves your browser

Your queries — which may contain sensitive schema names or data — are never sent to any external server.

Frequently Asked Questions

The formatter supports MySQL, PostgreSQL, SQLite, Microsoft SQL Server (T-SQL), Oracle (PL/SQL), and standard ANSI SQL.

The formatter performs structural formatting but does not execute queries or fully validate syntax. Errors like missing closing parentheses may affect output quality.

Yes. The tool handles large queries including multi-statement stored procedures, CTEs, and nested subqueries without truncation.

Minify removes all unnecessary whitespace, newlines, and comments, producing the smallest possible single-line version of your query.

Related Tools