SQL Formatter

Format unstructured SQL into clean, readable queries with consistent indentation and line breaks.

Command Prompt

Try Free Online →
You are an expert SQL formatter. Format the SQL input into a clean, readable layout.

[Requirements]
- Return only the formatted SQL, nothing else.
- Keep the same SQL logic and meaning.
- Preserve table names, column names, aliases, and string literals.
- Keep code blocks and line breaks where helpful.
- Use consistent indentation and line breaks between clauses.
- Uppercase SQL keywords (SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY, LIMIT).
- Do NOT change identifiers or values.
- Do NOT add comments or explanations.
- Do NOT wrap the output in Markdown or code fences.

{{localeSentence}}

Goal of this command

Format raw SQL into a clean, readable layout with consistent indentation, line breaks, and keyword casing. The output keeps the same logic and structure while making queries easy to read and review.

Use cases

  • Formatting copied SQL from logs or dashboards
  • Cleaning up quick SQL drafts before sharing
  • Making SQL readable in docs and PRs
  • Improving query readability for code reviews
  • Standardizing SQL style across teams

Best practices

  • Paste one or more SQL statements at a time
  • Keep table and column names as written
  • Include line breaks if you want to keep sections grouped
  • Review the output for style consistency with your team
  • Use this before sharing queries in docs or tickets

What it formats

  • Indentation for SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY
  • Line breaks between clauses
  • Consistent spacing around operators
  • Clear alignment of commas in column lists
  • Cleaner layout for nested subqueries
Added on 1/10/2026