SQL Formatter

Paste a one-line query and get indented SQL back. It is meant for reading and editing statements, not for connecting to a database.

Runs entirely in your browser. Nothing you paste or upload is sent to a server.

What is SQL Formatter?

A SQL formatter rewrites a statement so clauses sit on their own lines and keywords such as SELECT, FROM, JOIN, and WHERE are uppercase. It does not open a database connection, run the query, or check that the tables exist.

Use it when a log, an ORM dump, or a chat message gives you SQL on one line. The result is easier to review. It is still your job to confirm the statement against the dialect you actually run. If the line is a JSON API body rather than a statement, use the JSON formatter instead.

How to use it

  1. Paste a SQL statement.
  2. Run Format to indent clauses.
  3. Copy the formatted query into your editor.

Useful for

  • Read a minified query
  • Line up JOIN and WHERE clauses
  • Clean SQL before a code review

Example

A one-line query is split so each clause starts on its own line. Keywords are uppercased. The page does not execute the statement.

select id, name from users where active = 1
SELECT id,
  name
FROM users
WHERE active = 1

Related tools

Questions about SQL Formatter

Which SQL dialects work? +

The formatter is dialect-agnostic and works well with MySQL, PostgreSQL, SQLite, and most ANSI SQL.

Is my query sent anywhere? +

Never. Formatting happens locally in the browser.

How do I format a SQL query online? +

Paste the statement and run Format. Keywords such as SELECT, JOIN, and WHERE move onto their own lines and are uppercased.

Does this run the query? +

No. It only rewrites the text. It does not connect to MySQL, PostgreSQL, or any other database.

Will it fix an invalid query? +

No. It changes spacing and keyword case. A missing table, a bad join, or a syntax error is still yours to fix.