SQL Formatter

NEW

Format messy SQL into readable code

FreeNo sign-upDeveloper Tools →

SQL Formatter reformats a SQL statement so it is readable: keywords are uppercased and the main clauses, such as SELECT, FROM, WHERE, JOIN, GROUP BY and ORDER BY, are placed on their own lines with consistent indentation.

It is a rule-based formatter that runs in your browser. It does not connect to a database or validate the query, and it handles common SELECT, INSERT, UPDATE and DELETE statements best. Very dialect-specific syntax may need manual adjustment afterwards.

Advertisement

How to use SQL Formatter

1

Paste the query

Minified or messy SQL is fine.

2

Format

Generate the reformatted version.

3

Copy

Paste it back into your editor.

Use Cases

  • Making a query from an ORM log readable
  • Tidying SQL before a code review
  • Preparing a query for documentation

Frequently Asked Questions