Free Online SQL Formatter
Beautify long SQL queries into readable, consistently indented statements.
Tip: Ctrl + Enter to format · Ctrl + K to clear
Formatted SQL will appear here.
How it works
- Paste one or more SQL queries.
- Choose your database dialect and keyword case.
- Click Format SQL to get clean, indented statements.
- Copy or download the result as query.sql — or compact it back to one line.
Frequently asked questions
Why choose a SQL dialect?
Databases differ in syntax — backtick identifiers in MySQL, :: casts in PostgreSQL, square brackets in SQL Server. Picking the right dialect helps the formatter understand these without errors.
Should SQL keywords be uppercase?
SQL is not case-sensitive for keywords, but UPPERCASE keywords (SELECT, FROM, WHERE) are a common convention that makes queries easier to scan. You can also keep your original casing.
Why do I get a parse error?
Usually the query uses syntax from a different database than the selected dialect, or has an unclosed quote or bracket. Try another dialect, or check quotes around strings.
Is my query or data sent anywhere?
No. Formatting happens in your browser, so queries containing table names or customer data stay private.
Format SQL queries for humans
Queries generated by ORMs or copied from logs are usually one long line. The SQL formatter breaks them into clauses — SELECT, FROM, JOIN, WHERE, GROUP BY — with consistent indentation, making complex joins and subqueries much easier to understand and review.
Supported databases
Choose from standard SQL, MySQL, MariaDB, PostgreSQL, SQL Server (T-SQL), SQLite, Oracle PL/SQL, Google BigQuery, Snowflake and Amazon Redshift. Each dialect understands its own quoting, operators and keywords.
Keyword case
Many teams write SQL keywords in UPPERCASE so they stand out from table and column names. You can also choose lowercase or keep the casing you typed. Identifiers, strings and comments are never changed.
Compact mode
Need the query back on one line for a script, log search or code string? Compact collapses whitespace and removes comments while leaving quoted strings intact.