SQL Formatter
Format and beautify SQL queries with clean indentation and readable structure.
SQL Input
Formatted SQL
About SQL Formatter
SQL Formatter formats messy, compressed or difficult-to-read SQL queries into a clean and readable structure. It supports several SQL dialects and lets you control keyword casing and indentation.
How to use SQL Formatter
- Paste your SQL query into the SQL Input area.
- Select the SQL dialect used by your query.
- Choose whether SQL keywords should use uppercase or lowercase.
- Select the indentation width.
- Click Format SQL to format the query.
- Use Copy to copy the formatted SQL.
What is SQL formatting?
SQL formatting is the process of adding consistent indentation, line breaks and spacing to SQL statements. Proper formatting makes queries easier to read, understand, review and maintain without changing the intended SQL structure.
Supported SQL dialects
| Dialect | Common Database |
|---|---|
| SQL Server / T-SQL | Microsoft SQL Server |
| MySQL | MySQL and compatible systems |
| PostgreSQL | PostgreSQL |
| SQLite | SQLite |
| Oracle PL/SQL | Oracle Database |
| BigQuery | Google BigQuery |
Keyword case
You can choose how SQL keywords are displayed after formatting. Uppercase formatting uses keywords such as SELECT and WHERE, while lowercase formatting uses select and where.
Indentation options
The formatter supports 2, 4 or 8 spaces for indentation. Choosing a consistent indentation width can make nested queries, subqueries and SQL expressions easier to read.
Why format SQL queries?
- Make long SQL queries easier to read
- Improve code review and maintenance
- Understand joins, conditions and nested queries
- Clean up compressed SQL copied from applications
- Keep SQL formatting consistent across projects
- Make database queries easier to troubleshoot
Does formatting change the SQL query?
The purpose of formatting is to improve the presentation of the SQL by adding structure, spacing and indentation. Always review formatted SQL before running it in a production database, especially when working with complex or dialect-specific queries.
Is my SQL uploaded to a server?
The formatting operation is performed in the browser using the SQL formatting library. The tool does not require sending your SQL query to a backend server.
Input limit
The SQL input and formatted output fields support up to 100,000 characters. Very large SQL queries may require additional processing resources depending on your browser and device.