SQL Formatter (Dialect-Aware)
A dialect-aware SQL beautifier for gnarly joins and subqueries — choose your engine, set keyword case and indentation, then copy the pretty-printed result.
Paste a cramped query and this SQL formatter rewrites it with real line breaks, aligned clauses and consistent keyword casing, tuned to the dialect you actually run. Pick PostgreSQL, MySQL, MariaDB, SQLite, Transact-SQL, Oracle PL/SQL, BigQuery, Snowflake or Redshift so the beautifier respects each engine's keywords and quoting instead of guessing. You control keyword case (UPPER, lower or preserve), indent width (2 spaces, 4 spaces or tabs), and a minify switch that collapses the whole statement onto one line for embedding in code. Formatting only touches whitespace and casing, so the query runs exactly the same before and after.
How it works
- 1
Choose your dialect
Set the dialect selector to the engine your query targets — PostgreSQL, MySQL, SQLite, BigQuery, Snowflake, Transact-SQL and more — so keywords and identifiers parse correctly for that database.
- 2
Set case and indentation
Pick whether keywords come out UPPERCASE, lowercase or untouched, and choose a 2-space, 4-space or tab indent. Flip on Minify to compress the formatted statement back to a single line.
- 3
Copy the formatted SQL
The right pane pretty-prints live as you type or change options. Copy it or download it as a .sql file — only whitespace and casing change, never the query's logic.
Instant & 100% private — nothing is uploaded
Everything runs locally in your browser. Your code, text and files are processed on your own device and are never sent to a server — so there are no upload waits, no size limits from us, and nothing is ever stored or logged.
Frequently asked questions
- How is this different from the code formatter that also does SQL?
- The general code formatter runs SQL through Prettier's single generic mode. This tool is dialect-aware: it uses the sql-formatter engine with per-dialect keyword lists and quoting rules, plus explicit controls for keyword case, indent width and one-line minify — better for complex joins, CTEs and window functions where dialect matters.
- Can I format PostgreSQL and MySQL queries differently?
- Yes. Switch the dialect selector and the same query is re-parsed with that engine's rules. A MySQL query using backtick-quoted identifiers formats correctly under MySQL, while a Postgres query with double-quoted identifiers and $1 placeholders formats correctly under PostgreSQL.
- What does the formatter do to a one-line query?
- Given select id,name from users where age>18 order by name with keyword case set to UPPER, it returns SELECT id, name FROM users WHERE age > 18 ORDER BY name — each clause on its own line, columns indented, operators spaced. Toggle Minify to fold it back to a single compact line.
- Does formatting change what my query returns?
- No. The beautifier only adjusts whitespace, line breaks and keyword casing. Table names, string literals, comments and logic are left intact, so the formatted statement executes identically to the original.
More tools
More from the Hivly network
Free sister tools on our other sites.