SQL Formatter
Pretty-print SELECT, JOIN, CTE, and DDL for PostgreSQL, MySQL, SQL Server, BigQuery, Snowflake and more — with dialect-aware keyword casing and indentation. Risk & lint findings, parsed schema, bind parameters, and a minified variant sit in the extended view. Nothing is executed; it runs in your browser.
Auto-formats as you type. Ctrl+Enter to re-run.
How to use the SQL Formatter
Beautify long, ORM-generated, or copy-pasted SQL queries into clean, readable code with consistent indentation, keyword casing, and line breaks. The SQL Formatter supports PostgreSQL, MySQL, SQL Server (T-SQL), BigQuery, Snowflake, SQLite, and standard SQL — and parses CREATE TABLE statements into a column and relation view. Everything runs in your browser; queries never leave your machine.
What it does
- Pretty-prints SELECT, INSERT, UPDATE, DELETE, MERGE, CTEs (WITH), window functions, and subqueries.
- Supports dialects: PostgreSQL, MySQL, SQL Server, BigQuery, Snowflake, SQLite, Redshift, and standard SQL.
- Configurable keyword casing (UPPER, lower, preserve) and indent (2, 4, tab).
- Preserves comments (
--and/* */) and string literals. - Parses CREATE TABLE schemas into a table view with columns, types, primary keys, and foreign-key relations (Analysis view).
- Flags risky patterns —
SELECT *,DELETE/UPDATEwithoutWHERE,DROP/TRUNCATE, missingON— and secret-like values, with a one-click mask before sharing. - Copy formatted SQL straight to your editor, ticket, or pull request.
When to use it
- Review a long query before approving a PR.
- Make ORM-emitted SQL (Hibernate, Sequelize, Django) human-readable for debugging.
- Clean up SQL pasted from slow-query logs, EXPLAIN output, or chat.
- Enforce team style on a CTE-heavy report query.
- Get a quick column and relation view from a
CREATE TABLEdump. - Prepare SQL for documentation or runbooks.
How to use it
- Paste your SQL into the editor.
- Pick the SQL dialect to get dialect-aware keyword handling.
- Choose keyword casing (UPPER recommended for readability) and indent size.
- The formatted SQL appears instantly; copy it, or switch Mode to Minify for a single-line form.
- For
CREATE TABLEinput, open the Analysis view to see columns, types, and relations. - For building lists of values, hand off to the SQL IN Clause Builder; for joins, try the SQL Join Builder.
Tips & pitfalls
- Pick the right dialect — quoting (
"vs`), reserved words, and functions differ across PostgreSQL, MySQL, and T-SQL. - Format does not validate — invalid SQL is still formatted best-effort, and no SQL is executed.
- Long
SELECTlists read best with one column per line; longWHEREclauses split onAND/OR. - Inline comments (
--) are preserved on their original lines; align them after formatting if needed. - For very long queries, format incrementally — large CTEs are easier to review in chunks.
FAQ
- How do I format SQL online? Paste the SQL and pick the dialect — the formatted result appears instantly. Copy the result.
- Which SQL dialects are supported? PostgreSQL, MySQL, SQL Server (T-SQL), BigQuery, Snowflake, SQLite, Redshift, and standard SQL.
- Does it run my SQL? No — only formatting and analysis. SQL is never executed or sent to a server.
- Can it format ORM-generated SQL? Yes — paste raw SQL emitted by Hibernate, Sequelize, ActiveRecord, or any ORM and the formatter handles it.
- How do I inspect a CREATE TABLE schema? Paste the
CREATE TABLEstatements and open the Analysis view to see columns, types, primary keys, and foreign-key links. - Is my SQL uploaded? No. Formatting runs entirely in your browser.
Runs locally in your browser. No uploads. No analytics on pasted SQL.