SQL Formatter & Beautifier
Beautify SQL queries with dialect-aware formatting, keyword casing, and indent control.
Formatted automatically as you type. Queries never leave your browser.
Format
Keyword case
Indent
How to format a SQL query online
Paste your SQL
Drop a query into the input. It is reformatted automatically a moment after you stop typing.
Pick the dialect and style
Choose from over a dozen SQL dialects, set keywords to UPPERCASE, lowercase, or unchanged, and pick 2 or 4 space indentation.
Copy the result
The formatted query appears in the output area, and Copy SQL puts it on your clipboard.
Why use this tool
Over a dozen SQL dialects
Standard SQL, PostgreSQL, MySQL, MariaDB, SQLite, T-SQL, Oracle, BigQuery, Snowflake, Redshift, and more each format with their own quoting and keyword rules.
Keyword case control
Force keywords to UPPERCASE or lowercase, or leave the casing exactly as written. Table and column names are never touched.
Indent control
Choose 2 or 4 space indentation so the formatted query drops straight into your codebase and matches your style guide.
Instant as you type
The query reformats automatically shortly after you stop typing. There is no format button to find.
Queries stay on your device
Formatting runs in your browser. Table names, schema details, and literal values are never uploaded.
About this tool
This SQL formatter takes a query that arrives as one long line, or as no particular style at all, and reprints it with consistent indentation, one clause per line, and predictable keyword casing. The usual suspects are machine-generated SQL from ORMs and query builders, statements copied out of logs, and long queries that have been edited by five people with five different ideas about line breaks. Formatting runs automatically a moment after you stop typing, so there is no button to press.
Over a dozen dialects are supported, including standard SQL, PostgreSQL, MySQL, MariaDB, SQLite, T-SQL, Oracle, BigQuery, Snowflake, and Redshift. The dialect setting matters because databases disagree about quoting, operators, and reserved words, and formatting with the wrong one can trip over otherwise valid syntax. Keyword casing can be forced to UPPERCASE or lowercase or left untouched, and indentation is 2 or 4 spaces, which covers most team style guides. Typical uses are standardizing style before a code review, making generated queries readable enough to debug, and normalising whitespace so two versions of a statement diff cleanly.
Everything happens on your device. Production queries routinely embed table names, schema details, and literal values such as emails and IDs, exactly the things you should not paste into a service that uploads input to a server. Here the query never leaves the browser tab. For the JSON your queries return, the JSON formatter does the same job, and CSV to JSON converts exported result sets. When a LIKE clause is not enough, the regex tester helps with the pattern matching you write in application code instead.
Frequently asked questions
- Which SQL dialects does the formatter support?
- Standard SQL, PostgreSQL, MySQL, MariaDB, SQLite, T-SQL (SQL Server), Oracle, BigQuery, Snowflake, Redshift, DuckDB, ClickHouse, Spark, Hive, Trino, Db2, SingleStore, TiDB, and N1QL. Pick the dialect that matches your database, since quoting rules and reserved words differ between them and the wrong dialect can format valid syntax incorrectly or report an error.
- Does it validate my SQL?
- No, it formats. The tool has to understand enough of the query structure to reprint it, so badly broken syntax often produces an error, but a query that formats cleanly is not guaranteed to run. A misspelled column name, for example, formats fine and still fails on your database.
- Is my query uploaded anywhere?
- No. Formatting runs entirely in your browser and the query never leaves your device. That matters more for SQL than most text, since real queries tend to contain table names, schema details, and literal values from production data.
- Can I control keyword casing?
- Yes. Keywords can be forced to UPPERCASE, forced to lowercase, or left exactly as you wrote them. Only keywords like SELECT, FROM, and WHERE are recased; identifiers such as table and column names are always left as written.
- Is there a limit on query size?
- No fixed limit. Formatting happens in your browser tab, so very large scripts are bounded by your device memory rather than an upload cap. The output area scrolls instead of stretching the page, so long results stay manageable.
Related tools
JSON Formatter & Validator
Pretty-print, minify, or explore JSON as a collapsible tree, with syntax errors shown inline.
CSV to JSON
Paste CSV and get a clean JSON array of objects, with header detection and automatic number and boolean typing.
API Key Generator
Generate cryptographically random API keys and tokens in hex, base62, or base64url, with control over length, an optional prefix, and bulk output.
ASCII Table Reference
The full ASCII character set with decimal, hex, octal, binary, and HTML codes. Search by code, character, or name.
Atbash Cipher
Mirror the alphabet so A swaps with Z, B with Y, and so on. Atbash is its own inverse, so one field both encodes and decodes as you type.
Base32 Encoder and Decoder
Encode text to standard Base32 and decode Base32 back to text, following RFC 4648.