How to format SQL queries so they are easy to read

Long SQL on one line is hard to review. SQL formatter lays it out clearly.

Steps

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

Use cases

  • Code reviews and documentation.
  • Understanding queries from logs.
  • Cleaning generated SQL.

Tips

  • Formatting never changes results, only layout.
  • Put each clause (FROM, WHERE, GROUP BY) on its own line.
  • Compare two versions with the Text diff tool.

All guides

↑ ↓ navigateEnter openEsc close