Tool overview
What is a SQL Formatter & Beautifier?
A SQL formatter beautifies or minifies SQL queries with dialect-aware keyword casing and indentation for 13 engines—from Postgres to Snowflake and BigQuery.
Why use this SQL Formatter?
Clean up log dumps, ORM output, and warehouse SQL locally before review—without uploading proprietary queries to a hosted beautifier.
Key Features
13 dialects, Beautify/Minify, strip comments, collapsible output, parse errors with line hints, and 100% client-side formatting.
How to Use
Follow these steps to get accurate results from the tool interface above.
- Paste SQL into the left SQL QUERY panel, upload a .sql file from the session toolbar, or drag and drop onto the empty state.
- Select your dialect from the header dropdown (grouped: Core relational, Cloud warehouses, Big data, Enterprise).
- Check Strip comments when you want -- and /* */ removed before output; leave unchecked to keep annotations.
- Choose Beautify for indented, uppercase-keyword SQL or Minify for a single compact line.
- Click Process or press Ctrl/Cmd+Enter to format immediately; otherwise output updates automatically after a short debounce.
- Use Expand all / Collapse all on formatted output when reviewing large SELECT trees.
- Copy, download, or Swap output back to input for another pass with a different mode or dialect.
- Share ?dialect=snowflake&mode=minify in the URL to open the same settings (SQL text stays local).
SQL Formatter reference
Dialect list, workspace controls, Beautify vs Minify behavior, use cases, and comment-stripping rules.
SQL Formatter guide — start here
This page is the canonical guide to formatting and minifying SQL in the browser with DevUtilities. Use the SQL Formatter above while you read, or jump to a topic below. All parsing and formatting runs in your browser via sql-formatter — queries, schema names, and sample data are never uploaded.
What SQL Formatter does
SQL Formatter beautifies multi-line SQL for humans and minifies SQL for transport. It uppercases keywords automatically (SELECT, FROM, WHERE), applies clause-aware indentation, and respects dialect-specific grammar from the sql-formatter library — the same engine used by many IDE extensions and CLI formatters.
What you get
- Symmetric dual-pane workspace: SQL query input on the left, formatted or minified output on the right
- 13 dialect parsers grouped as Core relational, Cloud warehouses, Big data, and Enterprise
- Beautify and Minify modes with live auto-format (debounced) and an explicit Process button
- Dialect picker and Strip comments toggle in the panel header — no extra row stealing editor height
- Collapsible formatted output for large SELECT trees (Beautify mode)
- Parse errors with line and column hints when the dialect parser cannot read your input
- Optional URL sharing: ?mode=minify&dialect=postgresql persists mode and dialect
Use this tool when
- You paste ad-hoc SQL from a log, BI tool, or ORM and need readable indentation before review
- You embed SQL in application code and want a one-line minified string
- You work across PostgreSQL, Snowflake, BigQuery, Spark, or Oracle and need the parser to recognize dialect keywords
- You want to strip block and line comments before committing or shipping a query
Do not expect
- Semantic validation — formatting success does not mean the query will execute on your server
- Automatic query planning, linting for performance, or schema-aware rewrites
- Perfect preservation of every exotic vendor extension not covered by the selected dialect
- Server-side EXPLAIN or execution — this is a layout and whitespace tool only
Workspace layout & header controls
Controls live in the SQL QUERY panel header so input and output editors stay the same height. There is no separate options row below the toolbar.
Header controls (left panel)
| Control | Location | What it does |
|---|---|---|
| Dialect dropdown | Header, left of mode tabs | Selects the sql-formatter language parser (grouped by Core, Cloud, Big data, Enterprise) |
| Strip comments | Header checkbox | When checked, removes -- line, /* block */, and dialect-specific comments before Beautify or Minify |
| Beautify / Minify | Header mode tabs | Beautify applies indentation and uppercase keywords; Minify collapses whitespace |
| Process | Header primary button | Re-runs format immediately (also Ctrl/Cmd+Enter). Auto-format runs after ~350ms when input or options change |
| Swap | Center divider | Moves output to input and re-processes with the current mode |
Keyboard shortcuts
- Ctrl/Cmd+Enter — Process
- Ctrl/Cmd+L — Clear workspace
Supported SQL dialects (13 parsers)
Always pick the dialect that matches where the query will run. The parser uses different keyword lists, function names, and comment rules per dialect. Standard SQL is a safe default for generic ANSI-style snippets.
Supported dialects
| Group | Dialect | sql-formatter id | Typical use |
|---|---|---|---|
| Core | Standard SQL | sql | Generic ANSI-style queries |
| Core | PostgreSQL | postgresql | Postgres, Supabase, Cockroach (approx.) |
| Core | T-SQL / SQL Server | transactsql | Microsoft SQL Server, Azure SQL |
| Core | MySQL / MariaDB | mysql | MySQL, MariaDB (# hash comments) |
| Core | SQLite | sqlite | SQLite, mobile/local DBs |
| Cloud | Snowflake | snowflake | Snowflake worksheets, dbt on Snowflake |
| Cloud | Google BigQuery | bigquery | BigQuery console, scheduled queries |
| Cloud | Amazon Redshift | redshift | Redshift, Postgres-compatible warehouse SQL |
| Big data | Spark SQL | spark | Databricks, Spark SQL notebooks |
| Big data | Trino / Presto | trino | Trino, Presto, federated query engines |
| Big data | Apache Hive | hive | HiveQL, legacy Hadoop stacks |
| Enterprise | Oracle PL/SQL | plsql | Oracle Database procedures and SQL*Plus scripts |
| Enterprise | IBM DB2 | db2 | Db2 LUW and enterprise warehouses |
Cassandra CQL is not supported — it is not part of the sql-formatter dialect set. Use a CQL-specific formatter for Cassandra workloads.
Beautify vs Minify — which mode to use
Beautify and Minify share the same dialect picker and Strip comments checkbox but produce different output shapes.
Mode comparison
| Beautify | Minify | |
|---|---|---|
| Output shape | Multi-line, indented | Single line (whitespace collapsed) |
| Keywords | Uppercased (SELECT, FROM, …) | Original casing preserved except comment removal |
| Comments (Strip off) | Removed before format | Whitespace only collapsed |
| Comments (Strip on) | Removed | Removed |
| Best for | Docs, migrations, code review | Embedded strings, logs, payload size |
| Output view | Collapsible fold tree for large queries | Plain text output |
Example
Input: select id, name from users where active = 1 — Beautify yields indented lines with SELECT / FROM / WHERE uppercase. Minify with Strip comments off yields a single line: select id, name from users where active = 1.
Step-by-step: format SQL in the browser
- Open SQL Formatter from the sidebar under Formatters.
- Paste SQL into the left editor, upload a .sql file from the session toolbar, or drag and drop a file onto the empty state.
- Choose the dialect that matches your database (e.g. snowflake for a Snowflake worksheet query).
- Optionally check Strip comments if the input contains -- or /* */ annotations you do not want in output.
- Select Beautify for readable SQL or Minify for a compact single line.
- Review output on the right. Fix any parse error banner — click to dismiss after editing the input.
- Copy, download, or swap output back to input for another pass.
- Share a link with ?dialect=bigquery&mode=minify when you want collaborators to open the same settings.
Use case: migration files & ORMs
Flyway, Liquibase, and ORM migration files are easier to review when SELECT lists, JOIN blocks, and WHERE clauses break onto consistent lines.
Workflow
- Set dialect to postgresql, transactsql, mysql, or sqlite to match your migration target.
- Paste the raw migration SQL from a generated diff or ORM output.
- Beautify with Strip comments off if inline comments document intent.
- Copy formatted SQL back into the migration file before opening the PR.
Tip
Formatting does not validate against your live schema. Run migrations in a staging database after cosmetic changes.
Use case: Snowflake, BigQuery & Spark SQL
Analytics engineers often copy SQL from Snowflake, BigQuery, or Redshift consoles with inconsistent casing and collapsed lines.
Snowflake / BigQuery / Redshift
- Select snowflake, bigquery, or redshift before Beautify so warehouse-specific functions parse correctly.
- Use Strip comments when exporting from a notebook that includes -- session notes.
- For very wide SELECT lists, use the output fold controls (Expand all / Collapse all) after Beautify.
Spark / Trino / Hive
- Pick spark for Databricks notebooks and Spark SQL pipelines.
- Pick trino for Presto-compatible federated queries across catalogs.
- Pick hive for legacy HiveQL scripts — parser coverage follows sql-formatter Hive dialect rules.
Use case: minify SQL for embedded strings
Application code often stores SQL as a template string. Minify reduces bytes and escapes when you need one line inside JavaScript, Python, or Go source.
- Paste the readable SQL version into the input panel.
- Enable Strip comments if developers left debugging notes in the query.
- Switch to Minify mode.
- Copy the single-line output into your string literal (watch quote escaping in your language).
If you need readable SQL in source but compact SQL at runtime, keep the beautified version in docs and minify only for the build artifact.
Use case: PR and code review cleanup
Normalize SQL before review so diffs focus on logic, not whitespace noise.
- Beautify both sides of a comparison when a teammate pastes one-liner SQL into a ticket.
- Use uppercase keywords as a consistent style — the formatter applies this automatically in Beautify mode.
- Pipe output from Text Diff after formatting two versions if you need a semantic diff of query text.
Strip comments — behavior by dialect
The Strip comments checkbox applies to both Beautify and Minify. When enabled, the tool removes comments before formatting using dialect-aware rules where implemented.
Comment stripping behavior
| Syntax | Handled when Strip is on |
|---|---|
| -- line comments | Yes (replaced with space, then whitespace normalized) |
| /* block comments */ | Yes |
| MySQL # hash comments | Yes when dialect is mysql |
| PostgreSQL $$ dollar quotes | Preserved — content inside $$…$$ is not treated as comments |
| Redshift dollar quotes | Same preservation as PostgreSQL dialect |
When Strip is off (Minify)
Minify still collapses whitespace to a single line but keeps comment text in place. Use this when comments must ship with the query.
Fix: parse errors and line hints
When the parser fails, a red banner shows Parse error with line and column numbers. The input editor highlights the error line when available.
Common fixes
- Wrong dialect — switch to the engine you actually use (e.g. plsql for Oracle packages, not Standard SQL).
- Unclosed string or parenthesis — balance quotes and parentheses near the reported line.
- Trailing comma or incomplete clause — finish SELECT lists and CTEs before formatting.
- Non-SQL pasted — remove shell or JSON wrappers around the query.
- Dialect-specific syntax in generic mode — try the vendor dialect or simplify unsupported extensions.
If a valid query still fails, the sql-formatter parser may not cover that syntax variant. Report upstream or format a simplified subset manually.
Privacy — queries stay in your browser
SQL Formatter runs 100% in your browser. The sql-formatter library is loaded dynamically; formatting executes on the main thread in JavaScript.
- No query text is sent to Dev Tools Suite servers
- Input, output, dialect, and Strip comments preference can persist in localStorage on your device
- URL query params (?dialect=, ?mode=) only reflect settings — they do not contain your SQL body
- Clear the workspace (Ctrl/Cmd+L) after working with production data or PII
SQL formatting best practices
- Match dialect to execution environment before Beautify — formatting success ≠ runtime success
- Use Beautify for humans, Minify for machines
- Keep Strip comments off when comments document business rules; turn on for exports and embedded strings
- Verify minified output on a staging database when dollar-quoted strings or exotic literals are present
- Use session history and file upload for large scripts instead of pasting into chat apps that alter quotes
- Combine with Text Diff when comparing two formatted versions of the same report query
Frequently Asked Questions
Expandable answers for common debugging bottlenecks and data privacy questions.
Related tools
Explore other related utilities that complement this tool.
Official Documentation & References
Authoritative specifications and platform documentation for this utility.