SQL Formatter
Format SQL queries into readable, consistently indented statements.
SQL Formatter
Developer tool running locally in browser
What does SQL Formatter do?
Beautify SQL with keywords aligned, clauses on their own lines and joins indented, across several dialects. A long unformatted query becomes something you can actually review.
How to Use SQL Formatter
- 1Paste your queryOne statement or several.
- 2Pick your dialectThis affects how quoting and functions are handled.
- 3Copy the formatted SQLReady for review or a migration file.
Key Features
- Dialect support for MySQL, PostgreSQL, SQL Server, SQLite, BigQuery, Snowflake and standard SQL
- Keywords cased consistently, upper or lower
- Clauses and joins on their own lines with subqueries indented
- Configurable indent width
- Comments preserved
Frequently Asked Questions
Does formatting change what the query does?
No. Only whitespace, line breaks and keyword casing change. The parsed statement is identical, so results and the execution plan are unaffected.
Why does the dialect matter?
Because identifier quoting and reserved words differ — MySQL uses backticks, PostgreSQL and standard SQL use double quotes, SQL Server uses square brackets. Picking the right dialect avoids mangling identifiers.
Should SQL keywords be uppercase?
It is a strong convention because it separates language from identifiers at a glance, which matters in long queries. SQL itself is case-insensitive for keywords, so it is purely a readability choice.
Can it format stored procedures?
Basic procedural blocks format reasonably. Deeply nested dialect-specific procedural code — PL/pgSQL, T-SQL control flow — may need manual tidying afterwards.
Input is processed in your browser and never transmitted. That said, treat any web page as untrusted for live production secrets — rotate anything you paste anywhere.
Related Tools
SQL Minifier
Collapse a SQL query onto a single compact line.
JSON Formatter
Format, validate and explore JSON with precise error reporting.
CSV to JSON Converter
Convert CSV or spreadsheet data into clean JSON.
JavaScript Formatter
Beautify JavaScript, TypeScript and JSX code.
