SQL Formatter & Prettifier Online
Beautify messy SQL into readable, consistently indented statements for MySQL, PostgreSQL, SQL Server, Oracle, SQLite, BigQuery, Snowflake and more. Choose keyword case, indentation and layout style - or minify queries for logs and URLs. Everything runs in your browser.
SQL Formatter Workspace
Paste one or many statements. Pick the dialect so vendor-specific syntax (T-SQL brackets, PostgreSQL casts, BigQuery backticks) is understood.
SELECT
o.id,
c.name AS customer,
sum(oi.qty * oi.unit_price) total,
o.created_at
FROM
orders o
JOIN customers c ON c.id = o.customer_id
LEFT JOIN order_items oi ON oi.order_id = o.id
WHERE
o.status IN ('paid', 'shipped')
AND o.created_at >= '2026-01-01'
GROUP BY
o.id,
c.name,
o.created_at
HAVING
sum(oi.qty * oi.unit_price) > 100
ORDER BY
total DESC
LIMIT
20;Why Developers Use the Agenvix SQL Formatter
Readable queries are reviewable queries.
Dialect-Aware Parsing
The formatter tokenises with the grammar of your database, so T-SQL [brackets], PostgreSQL :: casts, MySQL backticks and BigQuery struct syntax are formatted correctly instead of mangled.
Your Team Style
Upper, lower or preserved keyword case, 2/4-space or tab indentation, standard or tabular alignment and configurable blank lines between statements.
Minify for Logs & URLs
Collapse a query to one line - comments removed, spacing normalised - for log lines, HTTP parameters or compact migration files.
Production Queries Stay Private
Queries reveal schemas and sometimes data. Formatting runs locally; nothing is sent to a server or stored.
Simple as 1-2-3
How the Formatter Works
Paste, choose, copy.
Paste SQL
One statement or a whole migration script - SELECT, INSERT, UPDATE, DDL, CTEs and window functions are all supported.
Choose Dialect & Style
Pick the database, keyword case, indentation and layout. Changes re-format instantly.
Copy or Download
Copy the formatted SQL or download a .sql file for your repository.
Dialect Differences the Formatter Understands
Why picking the right dialect matters.
| Feature / Specification | Best Use Case | Engine / Output Standard | Privacy & Security | Performance Rating | Action |
|---|---|---|---|---|---|
| PostgreSQL | :: casts, $$ bodies, RETURNING | Full support | Also Redshift, DuckDB | Supported | |
| MySQL / MariaDB | `backtick` identifiers, LIMIT x,y | Full support | Also TiDB, SingleStore | Supported | |
| SQL Server (T-SQL) | [bracket] names, TOP, @variables | Full support | GO batches kept | Supported | |
| BigQuery / Snowflake | STRUCT, ARRAY, QUALIFY | Full support | Cloud warehouses | Supported | |
| Oracle PL/SQL | Packages, (+) joins | Statements only | Blocks formatted as text | Partial |
Writing SQL People Can Read
1. Why formatting matters in SQL
SQL is whitespace-insensitive, so the database does not care - but reviewers, on-call engineers and your future self do. One clause per line, indented sub-expressions and consistent keyword case make it obvious which JOIN feeds which filter, where a missing ON condition hides, and why a GROUP BY does not match the SELECT list. Formatted queries also diff cleanly in pull requests.
2. Choosing a style and sticking to it
Upper-case keywords with lower-case identifiers is the most common convention and the default here. Tabular layouts (left or right aligned) put keywords in a fixed-width column so clauses line up vertically - popular in data-warehouse teams. Pick one style, add it to your contributing guide, and format on save.
Leading commas, dense operators and blank lines between statements are matters of taste; the options above let you reproduce whatever your linter (sqlfluff, SQLFluff-style rules, dbt conventions) expects.
3. When to minify instead
Minified SQL belongs in places where line breaks are costly: structured log fields, query parameters, HTTP headers, or inline strings in code that is itself formatted. Minification strips comments by default - keep them if the comment carries an optimizer hint such as /*+ INDEX(...) */.
4. Safety and limits
The formatter never executes anything; it only re-arranges whitespace and keyword case, so the semantics of your query are unchanged. It is a formatter, not a validator: syntactically broken SQL will still be formatted on a best-effort basis, and the status line tells you when the parser hit something it did not understand so you can inspect that spot.
Everything you need to know about formatting SQL
Dialects, options, minifying and privacy.
How do I format a SQL query online?
Paste the query, choose your database dialect and style options, and the formatted SQL appears instantly. Copy it or download a .sql file.
Which SQL dialects are supported?
Standard SQL, MySQL, MariaDB, PostgreSQL, SQLite, SQL Server (T-SQL), Oracle PL/SQL, BigQuery, Snowflake, Redshift, Spark, Hive, Trino/Presto, Db2, ClickHouse, DuckDB, SingleStore, TiDB and Couchbase N1QL.
Does formatting change what the query does?
No. Only whitespace, line breaks and keyword letter case are changed. Identifiers, string literals and comments are left exactly as written.
Can it format multiple statements at once?
Yes. Paste a whole script; each statement is formatted and separated by the configured number of blank lines.
What does minify do?
Minify collapses the SQL to a single line, removing comments and redundant spaces while keeping string literals intact - useful for logs, URLs and compact code strings.
Why did I get a parse warning?
The formatter reports when a token is unexpected for the chosen dialect - often a syntax error, or a vendor-specific construct. Try the correct dialect first; otherwise fix the statement and re-format.
Is my SQL uploaded?
No. The formatter library loads into your browser on first use and all formatting happens locally.
Related Developer Utilities
Discover companion utilities engineered for zero-log speed and browser-side execution.
CSV to SQL Converter
Convert CSV to CREATE TABLE and batched INSERT statements for MySQL, PostgreSQL, SQLite and SQL Server.
JSON Formatter & Validator
Prettify, format, repair syntax errors, and convert raw JSON data strings into trees.
XML Formatter & Beautifier
Beautify, minify and validate XML, RSS, SOAP and SVG with error line numbers and an XML to JSON view.
YAML to JSON / JSON to YAML Converter
Convert YAML to JSON and JSON to YAML with validation, multi-document support, key sorting and indent control.
Text Diff Checker
Compare two text blocks with LCS line matching, word level highlighting and similarity scoring.
Case Converter
Switch text between UPPER, lower, Title, Sentence, camelCase, snake_case and kebab-case instantly.
More in Code & Data
Specialized utilities within the same technical domain
