---
title: "SQL Formatter | RewriteBar Commands"
description: "Format unstructured SQL into clean, readable queries with consistent indentation and line breaks."
url: "https://rewritebar.com/prompts/sql-formatter"
---

[Back to all commands](https://rewritebar.com/prompts)

# SQL Formatter

[Development](https://rewritebar.com/prompts/categories/development)

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

## Command Prompt

[Try Free Online →](https://rewritebar.com/tools/sql-formatter)

```
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

### Tags

[sql](https://rewritebar.com/prompts/tags/sql)[format](https://rewritebar.com/prompts/tags/format)[database](https://rewritebar.com/prompts/tags/database)[query](https://rewritebar.com/prompts/tags/query)[developer](https://rewritebar.com/prompts/tags/developer)

Added on 1/10/2026
