SQL Formatter
Format and beautify SQL queries client-side with support for popular dialects. Your queries never leave the browser.
Input
Formatted output
What this SQL formatter does
Format and beautify SQL queries with support for MySQL, PostgreSQL, SQLite, SQL Server, BigQuery, Snowflake and other dialects. Formatting happens in your browser, so your queries — including any embedded data — never leave the page.
How it works
Tokenize. The query is split into tokens: keywords, identifiers, strings, numbers, and punctuation.
Respect strings and comments. Content inside string literals and comments is never reformatted or re-cased, so your data stays byte-for-byte identical.
Layout. Clauses such as
SELECT, FROM, WHERE and JOINstart on new lines, and subqueries are indented. Choose uppercase or lowercase keywords to match your house style.Dialect-aware. Picking the right dialect improves formatting of dialect-specific syntax like PostgreSQL array operators or MySQL's
ON DUPLICATE KEY.