Skip to content
ToolMug

SQL Formatter

Turn long one-line queries into readable SQL with each clause and column on its own line. Pick your database dialect so its syntax, quoting and functions are handled correctly.

Runs in your browser — nothing you enter is uploaded

How to use

  1. Paste your query, or click Load sample.
  2. Choose the SQL dialect, indentation and keyword case.
  3. Click Format, or press Ctrl+Enter (⌘+Enter on Mac).
  4. Copy the formatted query.

Options explained

SQL dialect
Handles dialect-specific syntax such as backtick identifiers in MySQL, :: casts and $1 parameters in PostgreSQL, square brackets in SQL Server and QUALIFY in Snowflake and BigQuery.
Keywords
UPPER writes SELECT, FROM, WHERE in capitals; lower writes them in lower case; Keep leaves them as typed. Table and column names are never changed.

Examples

Before

select id,name from users where status='active' order by name

After

SELECT
  id,
  name
FROM
  users
WHERE
  status = 'active'
ORDER BY
  name

Frequently asked questions

Does it check that my query is valid?

No. It formats the query's structure but does not check table names, column names or whether your database would accept it.

Can I format several statements at once?

Yes. Statements separated by semicolons are formatted one after another.

Is my query uploaded?

No. Formatting runs in your browser, so queries with real table names or data stay private.

Privacy

This tool runs entirely in your browser. Your files and text are processed on your device and are never uploaded to our servers.

Related tools