SQL Formatter
Paste any SQL — a one-liner from a log, a hand-written query, or a stack-traced procedure — and see it pretty-printed with consistent indentation, keyword casing, and lines between statements. Pick the SQL dialect for accurate handling of dialect-specific syntax (window functions, returning clauses, dialect keywords). The formatter runs entirely in your browser; no SQL leaves the page.
How to use
- Paste the SQL into the input.
- Pick the dialect (default Standard SQL works for most queries).
- Choose keyword case and indent width.
- Copy the formatted output.
Frequently asked questions
- Which dialects are supported?
- Standard SQL, PostgreSQL, MySQL, SQLite, MariaDB, T-SQL (SQL Server), BigQuery, Snowflake, Redshift, and Spark SQL — provided by the sql-formatter library.
- Does it execute the query?
- No — it only reformats text. The query is never run, parsed against a real database, or sent anywhere.
- Will it break on syntax errors?
- It's resilient — the formatter does its best on partially valid SQL and shows an error message only when the input can't be tokenized at all.
- Why are comments preserved oddly?
- SQL comments don't have a strict canonical position. The formatter keeps them attached to the nearest token, which sometimes shifts indentation a little.
Related tools
JSON Formatter & Validator
Format, beautify, minify, and validate JSON right in your browser.
XML Formatter & Minifier
Beautify XML with clean indentation or minify it to one line, in your browser.
YAML Formatter & Validator
Pretty-print and validate YAML — fix indentation, sort keys, choose line width, catch errors in place.
EditorConfig Generator
Build an .editorconfig file with indent style, line endings, charset and common overrides, in your browser.
Mock Data Generator
Generate realistic fake records for testing — names, emails, dates, IDs, lorem — exported as JSON, CSV, or SQL INSERTs.
String Escape Converter
Escape a string for 10 contexts at once — JavaScript, JSON, HTML entities, URL, SQL, regex, Bash (single/double quote), C string, Unicode \u escapes. Copy whichever you need.