0

SQL Formatter

Format and beautify SQL queries or minify them to one line — entirely in your browser.

Processing... 0%
Tokenizing SQL source
Detecting clauses and subqueries
Applying keyword casing
Rendering formatted output

Result

A 40-line query written in a hurry — everything lowercase, in one endless string, with three nested subqueries — is almost impossible to review. This SQL formatter turns it into readable, consistently indented SQL in one click: every column of the SELECT list gets its own line, JOINs line up under the FROM clause, WHERE conditions break at each AND/OR, and subqueries are indented one level deeper so the query's structure is visible immediately.

The formatter is built on a real SQL tokenizer, not on find-and-replace. That means it knows what it must never touch: string literals keep their exact content and spacing, -- and /* */ comments survive formatting, and identifiers quoted with double quotes, backticks or [brackets] pass through byte-for-byte. Keyword uppercasing is optional — turn it on to get SELECT, FROM, LEFT JOIN in caps regardless of how they were typed, or off to keep the original casing.

You choose the indentation width — 2 or 4 spaces — to match your team's style guide, and the mode: formatting for humans or minification to a single line for logs, JSON payloads and config files. Multiple statements separated by semicolons are handled in one pass, and the summary tells you how many were processed.

Everything happens locally in your browser: the query is tokenized and reassembled on your device and is never sent to any server. That makes the tool safe for real production SQL — with actual table names, schema details and business logic — which you should never paste into an online service that uploads your input. Works offline once the page is loaded; the result can be copied or downloaded as a .sql file.