# SQL Formatter

URL: https://hifreetools.com/developer/sql-formatter

> Paste a messy SQL query and get it cleanly formatted and indented, with control over the dialect, keyword case, and indent width — all live in your browser.

## Quick answer

A SQL formatter pretty-prints a query so it's readable: it puts clauses on their own lines, indents consistently, and standardizes keyword casing. Paste your SQL, choose the dialect (Standard SQL, MySQL, PostgreSQL, SQL Server, and more), and the formatted result appears instantly, ready to copy. It runs entirely in your browser, so your query is never uploaded.

The query is parsed into its clauses (SELECT, FROM, JOIN, WHERE, GROUP BY, and so on) and re-printed with each major clause on a new line, nested expressions indented by your chosen width, and keywords cased to upper, lower, or left as written. You can pick the SQL dialect so dialect-specific syntax is handled correctly.

## Examples

- One-line query: select * from users where id=1 → SELECT\n *\nFROM\n users\nWHERE\n id = 1
- Joins and grouping: A query with JOIN and GROUP BY → Indented, clause-per-line
- Choose the dialect: Dialect = PostgreSQL → Postgres-aware formatting

## FAQ

**Which SQL dialects are supported?**
Standard SQL plus MySQL, MariaDB, PostgreSQL, SQLite, SQL Server (T-SQL), BigQuery, and Snowflake, so dialect-specific syntax is formatted correctly.

**Can I control the keyword case?**
Yes. Choose UPPERCASE, lowercase, or preserve the original casing of SQL keywords.

**Is my query uploaded?**
No. Formatting happens entirely in your browser; the SQL never leaves your device.

**Does it validate my SQL?**
It formats the layout but doesn't check that the query is logically correct or will run. It reports an error only if it can't parse the structure.

**Can it minify SQL too?**
No. It focuses on readable formatting; the 2-space indent gives the most compact layout, but the goal is clarity, not minification.

**Does it handle comments?**
Yes, SQL comments are preserved in the formatted output.


## Sources

- [sql-formatter](https://github.com/sql-formatter-org/sql-formatter)
- [Wikipedia — SQL](https://en.wikipedia.org/wiki/SQL)

Runs in the browser; nothing is uploaded. Cite as: HIFreeTools, "SQL Formatter", https://hifreetools.com/developer/sql-formatter
