SQL Formatter

Format and beautify SQL queries. Supports SELECT, INSERT, UPDATE, DELETE, and complex JOINs.

About this calculator

Paste a one-line SQL query and get it formatted with line breaks and indentation. Works with SELECT, INSERT, UPDATE, DELETE and JOINs.

Readable SQL is easier to review and debug.

How to use it

  1. Paste your SQL.
  2. Press Format SQL.
  3. Press Copy.

Formatting rules

Major clauses (SELECT, FROM, WHERE, GROUP BY, ORDER BY, JOIN) start on new lines and column lists are indented. Keywords are upper-cased for readability. Formatting never changes what the query does.

Worked example

select id,name from users where age>18 order by name

FormattedSELECT id, name / FROM users / WHERE age > 18 / ORDER BY name

Tips and common mistakes

  • Upper-case keywords, lower-case table and column names.
  • One condition per line in WHERE.
  • Alias tables in joins.
  • Comment non-obvious logic.
  • Run EXPLAIN on slow queries.

Frequently asked questions

What does an SQL formatter do?

Adds line breaks and indentation for readability.

Does it change the query's meaning?

No.

Does it support all databases?

It handles standard SQL; dialect-specific syntax may format imperfectly.

Should keywords be upper-case?

By convention, yes.

Can it fix syntax errors?

No.

Is my SQL uploaded?

No.

Related tools