DEV

SQL Formatter

Paste a SQL query to break it onto readable lines at each major keyword, or collapse it back to one line.

INPUT
OUTPUT

          

How it works

Formatting looks for major SQL keywords (SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY and similar) and starts a new line before each one. It's a pattern-based formatter, not a full SQL parser — it doesn't validate that the query is syntactically correct.

Always review the output before running it — a formatter error in a destructive query (DELETE, UPDATE) is more costly than one in a SELECT.

Frequently asked

Does this validate my SQL syntax?

No — it only looks for keyword patterns to decide where to break lines. Invalid SQL will be reformatted without any error, since checking syntax would require a real parser for your specific database dialect.

Will this work for MySQL, PostgreSQL and SQL Server equally well?

The core keywords (SELECT, FROM, WHERE, JOIN, etc.) are shared across dialects, so formatting works similarly. Dialect-specific syntax may not be recognized as a line-break point.