Format and beautify SQL queries with clause line breaks and consistent keyword casing, or minify them to a single line.
How to use the SQL Formatter
Paste your SQL query into the input box.
Choose Format to beautify it or Minify to compress it to one line.
Pick the keyword casing, then copy the result.
This is a SQL formatter that takes a cramped, single-line or inconsistently styled query and beautifies it: each major clause on its own line, columns and conditions indented, and keyword casing made consistent. It can also do the reverse and minify a query to one line.
Readable SQL is easier to review, debug and maintain. When SELECT, FROM, WHERE, JOIN and GROUP BY each start a new line and the keywords share one casing, the shape of the query, what it returns and how it filters, becomes obvious at a glance.
Formatting is also useful right before committing a query so diffs stay small and reviewers see meaningful changes rather than reflowed whitespace.
You choose the keyword casing (for example uppercase keywords, which is the common convention) and whether to format or minify. The formatter is dialect-agnostic and handles the common ANSI SQL used by PostgreSQL, MySQL, SQLite and SQL Server.
Minify mode is handy for the opposite need: collapsing a formatted query back to a single line to embed in code or a config value.
The tool formats for readability rather than checking that your query is valid, so it will happily lay out a query with a typo in it. Treat clean output as a readability win, not a correctness check.
Everything runs in your browser, which matters because real queries often contain table names, column names and sometimes literal values that hint at your schema or data. None of that is uploaded.
Frequently asked questions
It puts each major clause such as SELECT, FROM, WHERE and JOIN on its own line, indents the columns and conditions, and normalizes keyword casing for readability.
No. Formatting runs entirely in your browser, so your queries never leave your device. That makes it safe for queries that mention table or column names.
It is dialect-agnostic and handles common ANSI SQL used by PostgreSQL, MySQL, SQLite and SQL Server. It formats for readability rather than validating syntax.
No. It lays out the text for readability but does not parse or run the query, so it will format a query even if it contains an error.
Yes. Minify mode collapses a formatted query to a single line, which is useful for embedding SQL in code or a configuration value.
Consistent layout makes queries easier to read, review and debug, and keeps version-control diffs focused on real changes instead of whitespace.
Embed this tool
Add this tool to your own website. Copy the snippet below; it stays up to date automatically.
<iframe src="https://monu.tools/embed/en/sql-formatter" width="100%" height="640" style="border:1px solid #e5e5e5;border-radius:12px;max-width:680px" loading="lazy" title="Monu Tools"></iframe>Related tools
Beautify XML with proper indentation, or minify it to a single line. Comments, CDATA and processing instructions are preserved.
Beautify CSS with clean indentation, or minify it to shrink file size. Handles media queries, calc() and license comments.
Beautify HTML with block-aware indentation, or minify it. The contents of pre, textarea, script and style are preserved.
Beautify and prettify JavaScript with consistent indentation and spacing. Runs entirely in your browser.