SQL Formatter & Beautifier

Paste a SQL query to pretty-print it with syntax highlighting, or minify it down to one line. Runs entirely in your browser.

Copied

Last updated

Input

Options

Run

Formatted or minified SQL will appear here.
Copied

About this tool

This is a generic, keyword-aware SQL formatter — it tokenizes your query (strings, numbers, comments, identifiers, and roughly 90 common SQL keywords, including multi-word ones like GROUP BY, LEFT OUTER JOIN, and IS NOT) and lays it out using standard beautifier conventions: major clauses (SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY, and so on) each start a new line, column and argument lists break one item per line, AND/OR get their own indented line, and subqueries in parentheses are indented one level deeper. It is not a real SQL parser for any specific database — it doesn't validate syntax or understand dialect-specific extensions, and a few constructs (parenthesized boolean groups, complex CASE expressions) are simplified rather than perfectly reflowed. For genuinely broken or dialect-exotic SQL, treat the output as a best-effort layout rather than a guarantee.

Minify strips comments and collapses all whitespace to the minimum needed to keep tokens apart, for the smallest possible query string. The keyword case toggle (uppercase/lowercase) and indent size (2 spaces, 4 spaces, or a tab) apply to formatting; identifiers, string contents, and comments are always left exactly as you typed them. Nothing you paste here is sent anywhere — the whole tool runs as JavaScript in your browser tab.