Home › Developer Tools › SQL Formatter
⛁

Free Online SQL Formatter

Beautify long SQL queries into readable, consistently indented statements.

Your data stays on your device. This tool processes everything directly in your browser. Nothing you enter is sent to our servers.

Tip: Ctrl + Enter to format · Ctrl + K to clear

Output
Formatted SQL will appear here.

How it works

  1. Paste one or more SQL queries.
  2. Choose your database dialect and keyword case.
  3. Click Format SQL to get clean, indented statements.
  4. 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.

Keyboard shortcuts

/
Search all tools
?
Show this help
Esc
Close search or dialogs
Ctrl + Enter
Run the tool's main action (Format, Generate, Calculate…)
Ctrl + K
Clear the tool's input

Tool shortcuts work while you're using a tool, including inside its text boxes.