SQL Formatter
NEWFormat and beautify SQL queries for MySQL, PostgreSQL, SQL Server, SQLite and more with keyword case and indent options.
Runs 100% in your browser — your input is never uploaded or stored on our servers.
Off: each dialect uses its own defaults (for example ? in MySQL, $1 in PostgreSQL, @name in T-SQL). On: only the styles you tick are kept intact, which also lets you format {name} or :name placeholders in dialects that do not support them by default.
Paste SQL above and press Format (or just wait — it formats as you type).
Quick Examples
Typical inputs and the results this tool produces.
Overview
This SQL formatter turns one-line or messy queries into readable, consistently indented SQL. Pick your dialect (MySQL, PostgreSQL, SQL Server, Oracle PL/SQL, SQLite, BigQuery, Snowflake, Spark and more) so each dialect-specific keyword, quoted identifier and operator is understood correctly.
Developers and analysts use it to read queries copied from logs and ORMs, tidy SQL before a code review, or keep migration files consistent. Control the indent width, keyword, function, data type and identifier case, indent style, where AND and OR break, expression width, blank lines between queries and more, or switch the result to a compact one-line-per-statement version.
Placeholders such as ?, $1, :name, @name and {name} can be kept intact. Everything runs in your browser using the open-source sql-formatter library, so your queries are never uploaded, and syntax problems are reported with a line and column.
Why use this tool?
- Dialect-aware formatting for 20 SQL flavours
- Control keyword, function and identifier case
- Keeps ?, $1, :name and @name placeholders
- Line and column shown for syntax errors
- Private: queries never leave your browser
Features
20 SQL dialects
Standard SQL, MySQL, MariaDB, PostgreSQL, SQL Server, Oracle, SQLite, BigQuery, Snowflake, Redshift, Spark, Hive, Trino, Db2, N1QL and more.
Case control
Set keyword, function, data type and identifier case to UPPERCASE, lowercase or preserved.
Layout options
Choose indent width or tabs, standard or tabular indent, AND/OR placement, dense operators and semicolon position.
Parameter handling
Choose which placeholder styles count as parameters: ?, $1, :name, @name, $name and {name}.
Error location
Unexpected tokens and unclosed brackets are reported with line and column, and the line is selected in the input.
Compact output
Collapse the result to one line per statement without touching strings, quoted names or comment text.
How to Use
Paste your SQL
Paste a query into SQL input, upload a .sql file, or load one of the dialect samples.
Select the dialect
Pick the SQL dialect that matches your database so its syntax is parsed correctly.
Set the options
Choose indentation, keyword case, indent style and, if you use placeholders, which styles to keep.
Copy or download
Press Format (or let it format as you type), then Copy, Download .sql or switch to Compact.