SQL Formatter

Format or minify SQL queries for readability. Supports SELECT, INSERT, UPDATE, DELETE, and common clauses. All in your browser.

Try it with this example

Paste a long SQL query and format it with newlines. Or minify for production.

What is this tool?

Long SQL queries are hard to read when everything runs together. The SQL Formatter pretty-prints SQL with indentation and line breaks. Keywords like SELECT, FROM, WHERE, and JOIN get their own lines; subqueries indent. The result is easier to read, diff, and review. Need to shrink for production? The tool can also minify—remove extra whitespace to reduce size. Supports uppercase or lowercase keywords. All processing runs in your browser. Your queries never leave your device.

Formatting follows common style: main clauses on new lines, logical indentation for nested queries and JOINs. The exact style may vary; the goal is consistency and readability. Minifying strips whitespace and newlines. It doesn't change logic or optimize—only layout. Invalid SQL may cause parse errors; fix syntax first. The formatter handles SELECT, INSERT, UPDATE, DELETE, and common DDL. Dialect-specific syntax (e.g. PostgreSQL vs MySQL) may parse differently.

Use it when inheriting a messy query and needing to understand it. When preparing SQL for a pull request or code review. When you want a quick minified version without a full build pipeline. For production, consider a linter (e.g. sqlfluff) for style enforcement. This tool is for ad-hoc formatting and readability. Paste, format, copy.

All processing is client-side. No server, no logging. Sensitive queries (with real table names, credentials in strings) stay local. Bookmark it for SQL cleanup. Pairs well with the JSON Formatter and other code formatters when working across languages.

Handy for developers and DBAs.