Dialect matters
SQL is a standard and also 30 dialects. Each vendor extended it: PostgreSQL added ::type casts,
MySQL added backticks, BigQuery added EXCEPT(...), Snowflake added
LATERAL FLATTEN. A dialect-unaware formatter mangles these or treats them as syntax errors.
Pick the dialect matching your target database. The formatter preserves dialect-specific syntax instead of flagging it.
Keyword case conventions
- UPPER (default) —
SELECT,FROM,WHERE. Oldest convention, most common in documentation and DBA tooling. - lower —
select,from,where. Modern convention in many application codebases (SQLAlchemy, Prisma docs). - preserve — leave as-is. Use when a style guide forbids auto-rewriting.
What the formatter will and won't do
Does:
- Insert newlines at clause boundaries (SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY)
- Align column lists, indent subqueries
- Normalize whitespace, strip trailing whitespace
- Preserve comments (both
--and/* */) - Respect dialect-specific syntax
Does not:
- Execute the query
- Validate referenced tables/columns exist
- Optimize or rewrite the query
- Send your SQL anywhere — it runs entirely in your browser
FAQ
Can I paste a stored procedure?
Yes — especially in T-SQL or PL/SQL modes. Complex control flow, variable declarations, and cursor loops format correctly.
Will it break on dialect mismatches?
Usually not — it will still format but may leave dialect-specific tokens un-indented. Match the dialect for best results.
Is my SQL uploaded anywhere?
No. The sql-formatter library runs in your browser.
Related tools
- JSON Formatter — Format, validate, and beautify JSON online. 100% client-side — your data never leaves your browser.
- YAML ↔ JSON Converter — Convert between YAML and JSON formats with full fidelity.
- Text Diff — Compare two text blocks line-by-line or word-by-word. Unified and split view. Shows added, removed, and changed segments with full color coding.
- Markdown Preview — Live Markdown preview with GitHub-flavored syntax. Tables, task lists, code blocks, strikethrough. Side-by-side editor and rendered output.
Pillar
Part of Data & Format.
Written by Mian Ali Khalid. Last updated 2026-04-25.