SQL formatter and beautifier
About SQL Formatter
The SQL formatter turns cramped or messy SQL into a readable layout: each clause on its own line, select columns and conditions indented, and subqueries and CTEs nested where they belong. Paste a query from app logs, an ORM trace, a migration or a database console.
Pick the dialect of your database: standard SQL, PostgreSQL, MySQL, SQLite, SQL Server (T-SQL), BigQuery, Oracle PL/SQL or Snowflake. Then choose upper, lower or unchanged keyword case and two- or four-space indentation.
Runs in your browser. Nothing is uploaded, and the tool never connects to a database or runs your SQL.
How it works
A real SQL parser per dialect
The query is parsed with the open-source sql-formatter library using the grammar of the dialect you pick, so dialect syntax such as PostgreSQL :: casts, T-SQL [bracketed] names, MySQL backticks or BigQuery STRUCT types is recognized instead of mangled.
Clauses, subqueries and CTEs laid out clearly
SELECT, FROM, WHERE, GROUP BY, ORDER BY and the other clauses start new lines with their content indented below. Joins line up under FROM, AND and OR start their own lines, CASE expressions break per WHEN, and subqueries and WITH blocks are indented inside their parentheses.
Literals and comments stay as written
String literals, quoted identifiers, numbers and comments keep their exact text. Keyword case applies to SQL keywords, function names and data types, never to table or column names.
Several statements at once
Paste a whole script. Each statement ends at its semicolon and is separated from the next by a blank line. If a statement cannot be parsed, the error shows the line and column, with a button that jumps to it.
Frequently asked questions
Does the formatter execute or validate my SQL?
No. It only reformats text and never connects to a database. A query that formats cleanly can still be invalid for your schema or database version. Use your database's parser or EXPLAIN for that.
Which SQL dialects are supported?
Standard SQL, PostgreSQL, MySQL, SQLite, SQL Server (T-SQL), Google BigQuery, Oracle PL/SQL and Snowflake. Pick the one your query was written for so its syntax is recognized.
Why do I get a parse error?
The formatter could not read the query in the selected dialect. Check the reported line and column for a missing parenthesis, a stray comma or an unclosed string, and make sure the dialect matches the database the query was written for.
Will formatting change strings or quoted identifiers?
No. Single-quoted strings, double-quoted identifiers, backtick and bracket identifiers and comments keep their original text. Only whitespace and the case of keywords, functions and data types change.
Can I use this tool with SQL containing secrets?
The SQL is formatted in your browser and never uploaded or run. Query logs can still contain passwords, tokens, emails and customer records. Redact sensitive values before you share the result.
Sources & last verified
We checked this tool's behavior and the claims on this page against the specifications below on . The tool runs in your browser, so the output you see is exactly what the engine produced.
Found a wrong result or an outdated claim? Report an error and we will check it again.