SQL Formatter

Beautify messy SQL queries with consistent indentation and keyword case for MySQL, PostgreSQL, SQL Server, SQLite and more.

Runs on your device

Result

Results appear here as you type.

What it does

Paste a one line query from a log or ORM and get readable, indented SQL. Formatting uses the open source sql-formatter library and never runs the query.

How to use it

  1. Paste your SQL.
  2. Choose the dialect and keyword case.
  3. Copy the formatted query.

Example

The example fills in realistic values and runs the tool. Select Try an example above to see it.

When it helps

  • Reading ORM-generated queries.
  • Code reviews.
  • Documentation and Stack Overflow questions.

Questions

Does it validate SQL?

It formats valid syntax and reports what it cannot parse, but it does not check tables or columns.

Is my query sent to a database?

No. Nothing is executed or uploaded.

More developer tools

See all 25

People also use

Browse all 200 tools