SQL Formatter & Beautifier
Instantly format and beautify SQL queries with configurable keyword casing, indentation style, and dialect-aware parsing. Supports MySQL, PostgreSQL, SQLite, T-SQL, PL/SQL, BigQuery, Snowflake, and 15+ more dialects. Everything runs in your browser.
Supported SQL Dialects
| Dialect | Best For |
|---|---|
| SQL (Generic) | Standard ANSI SQL — works with any database |
| MySQL / MariaDB | LAMP stack, WordPress, web apps |
| PostgreSQL | PostGIS, JSONB, advanced type support |
| SQLite | Embedded apps, mobile, local files |
| T-SQL | SQL Server, Azure SQL Database |
| PL/SQL | Oracle Database stored procedures |
| BigQuery | Google Cloud analytics, data warehousing |
| Snowflake | Cloud data warehouse |
| Redshift | AWS data warehouse |
| Spark SQL | Apache Spark distributed queries |
| DuckDB | Analytical SQL on local/Parquet files |
Formatting Options Explained
- Keyword Case:
UPPERCASEis the traditional SQL convention and the easiest to read at a glance.lowercaseis preferred by some teams for consistency with ORM-generated queries.preserveleaves keywords unchanged. - Indent Style: Standard indents sub-clauses under the parent keyword. Tabular Left/Right aligns keywords to a column, which some DBAs prefer for wide-screen reading.
- Tab Width: Most SQL style guides use 2 or 4 spaces. Setting to 4 matches many linter defaults.
- Lines Between Queries: When pasting multi-statement scripts, this controls how many blank lines to insert between each
;-terminated statement.
Why Format SQL?
- Code reviews: Consistent formatting makes query intent immediately clear, reducing review time.
- Debugging: Minified or single-line SQL is nearly impossible to read. Formatting reveals nested subqueries,
JOINconditions, andWHEREclause complexity at a glance. - Documentation: Well-formatted SQL embedded in README files or wikis is self-documenting.
- ORM debugging: ORMs like SQLAlchemy, Hibernate, and ActiveRecord can produce verbose, unformatted SQL — paste the raw query here to understand what's happening.
Frequently Asked Questions
Does this handle stored procedures and DDL?
Yes — CREATE TABLE, ALTER TABLE, CREATE PROCEDURE, and other DDL/DML statements are supported. For PL/SQL blocks with BEGIN…END, select the PL/SQL dialect for best results.
My query has custom functions — will they be preserved?
Custom function calls are treated as identifiers and will be preserved as-is. Only SQL keywords are reformatted by the formatter.
Is my SQL safe?
Absolutely. All formatting is done locally in your browser using the open-source sql-formatter library. No queries are ever transmitted to a server.