What is SQL Formatter?
SQL Formatter arranges keywords, clauses, lists, joins, and indentation with selectable generic SQL, MySQL, PostgreSQL, SQLite, and T-SQL dialects. It improves the readability of complex queries and review artifacts, but it never connects to a database, resolves real schema objects, or executes a statement. Common workflows include the following. Format a long query containing joins, subqueries, grouping, and ordering. Use the target database dialect in tickets, documentation, or source review. Make conditions, selected columns, and logical grouping easier to inspect before execution. The page also documents input boundaries, output behavior, and practical cautions so you can review the result before putting it into an application, configuration, test, or production workflow.
When to use it
- Format a long query containing joins, subqueries, grouping, and ordering.
- Use the target database dialect in tickets, documentation, or source review.
- Make conditions, selected columns, and logical grouping easier to inspect before execution.
How to use it
- Choose the closest database dialect.
- Paste SQL and select keyword case.
- Format and verify the result in the target database.
- Load one of the realistic examples first to verify the selected options and processing direction before replacing it with your own data.
- Review the output, status message, and documented limits; copy, download, or continue only after the result matches your expectation.
Runnable examples
The “Example 1” and “Example 2” buttons load the matching inputs. They cover different structures, directions, or boundaries and can be run directly in the workspace.
Example 1
select u.id,u.name,count(o.id) orders from users u left join orders o on o.user_id=u.id where u.active=true group by u.id,u.name order by orders descExample 2
select date_trunc('day',created_at) day,count(*) total from events where created_at>=now()-interval '30 days' group by day order by dayInput rules
- Choose the dialect closest to the target database before formatting.
- Input is text only and neither needs nor should include database credentials.
- Stored procedures, template placeholders, and vendor extensions depend on parser support.
- Text input is counted before processing and is limited to 500,000 characters on this page; file modes apply the separate file limit shown in the workspace.
- Formatting does not validate table names, columns, or permissions.
Output rules
- Output reorganizes whitespace, indentation, and common clauses for the selected dialect.
- Keywords may be uniformly upper- or lowercase without renaming identifiers or values.
- Formatting does not validate tables, columns, permissions, transactions, injection risk, or performance.
- Output reflects only the current input, direction, and options; rerun after changing a mode or value instead of treating an earlier result as current.
- Complex vendor extensions may not parse completely.
Limitations and cautions
- Formatting does not validate table names, columns, or permissions.
- Complex vendor extensions may not parse completely.
- Successful formatting is not a SQL security review.
How your data is handled
SQL is passed only to the local browser formatter. No database connection is opened, no query is executed, and no schema or history is stored.