SQL Formatter

Runs in your browserDeveloper Tools#Database#SQL

Format and beautify SQL in 20 dialects, with uppercase or lowercase keywords.

Formatted SQL
The formatted SQL appears here.
How to use, limits & privacy

About SQL Formatter

Make long SQL queries readable: each clause on its own line, columns and conditions indented, and keywords in the case you choose. It supports 20 dialects, including MySQL, PostgreSQL, SQL Server, Oracle PL/SQL, SQLite, BigQuery and Snowflake, and formats as you type in your browser.

How to Use

1

Paste your SQL

Paste a query or a whole script into the SQL box, or click Example. Several statements separated by ; are formatted together.

2

Choose the style

Pick your database under Dialect, UPPERCASE, lowercase or As typed under Keywords, and 2 spaces, 4 spaces or a tab under Indent.

3

Copy the result

Click Copy, or Download .sql to save formatted.sql. If the SQL can't be read, the error shows the line and column.

Privacy & Processing

  • Mode: local
  • Files Leave Browser: Local tool processing; review details below
  • Max Input Size: Device memory limits
  • Account Required: No
  • Data Stored Locally: Nothing is saved; the query stays in memory only while this page is open.
  • Network Processing: Assets or models may require an initial download

Your SQL is formatted in your browser and is never uploaded.

Rules & Limitations

  • Only spacing, line breaks and the case of keywords, functions and data types change. Table names, column names and text in quotes stay as they are.
  • It formats SQL but does not run it or check that tables and columns exist; use the SQL Playground to run queries.
  • Syntax that only one database has (MySQL # comments, SQL Server [brackets], PostgreSQL $1 parameters) needs that dialect selected.
  • Very long scripts (hundreds of KB) can take a moment to format.

Top Suggestions

  • Cleaning up a one-line query copied from logs or an ORM
  • Making SQL easier to review in a pull request
  • Keeping one keyword style across a team's queries
  • Reading stored procedures and reports written by someone else

SQL Formatter FAQ

How do I format a SQL query online?

Paste the query into the SQL box. It is formatted as you type; choose your database under Dialect and click Copy.

Can it change keywords to uppercase?

Yes. UPPERCASE is the default, so select becomes SELECT and count becomes COUNT. Choose lowercase or As typed under Keywords to change that.

Why does it say Parse error?

The formatter could not read the SQL at the line and column shown. Usually a bracket or quote is not closed, or the query uses syntax from another database; select that database under Dialect and try again.

Does formatting change what my query does?

No. Only whitespace and the letter case of keywords change, and SQL ignores both. Quoted text and identifiers are kept exactly.

Is my SQL sent to a server?

No. Formatting runs in your browser, so queries with table names or customer data stay on your device. Nothing is saved.