SQL Formatter
Format and beautify SQL queries with proper indentation, keyword capitalization, and clause separation. Supports SELECT, INSERT, UPDATE, DELETE, CREATE TABLE, and JOINs. Works with MySQL, PostgreSQL, and SQLite syntax.
Examples:
How to Use SQL Formatter
- 1Paste your SQL query into the input field.
- 2SQL keywords are capitalized and the query is reformatted with proper indentation.
- 3Clauses are separated onto new lines for easy reading.
- 4Copy the formatted SQL for use in documentation, code reviews, or database tools.
ZenovayAnalytics
See who's on your site right now.
- Real-time visitor tracking
- Privacy-first, no cookie banner
- Set up in two minutes
Related Tools
JSON Formatter & Validator
Format, validate, and beautify JSON data with syntax highlighting and error detection.JWT Decoder
Decode and inspect JWT tokens. View header, payload, and verify signatures.Base64 Encode/Decode
Encode text to Base64 or decode Base64 back to text. Supports UTF-8 and binary data.URL Encode/Decode
Encode or decode URL components. Handle special characters, query strings, and full URLs.Frequently Asked Questions
What SQL dialects does this formatter support?▾
This formatter works with standard SQL and most major dialects including MySQL, PostgreSQL, SQLite, SQL Server (T-SQL), and Oracle. It handles SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, WITH (CTEs), JOIN variants, subqueries, and CASE expressions. Dialect-specific syntax like PostgreSQL :: casting or MySQL backtick identifiers is preserved as-is.
Does this formatter change my query logic?▾
No — the formatter only changes whitespace and keyword casing. It never reorders clauses, modifies values, or changes identifiers. String literals (single-quoted values) are preserved exactly, including any whitespace inside them. The formatted SQL is semantically identical to the original.
Why are keywords uppercased?▾
SQL keywords in uppercase is a widely adopted convention (SQL standard uses uppercase in its own documentation). It visually separates reserved words from table names, column names, and aliases, making queries easier to read and debug. Most SQL style guides — including those from Google, GitLab, and dbt — recommend uppercase keywords.
How does the indentation work for JOINs and subqueries?▾
JOIN clauses are aligned with the FROM keyword at the same indentation level. ON conditions are indented one level. Subqueries inside parentheses are indented relative to their context. CTEs (WITH clauses) are formatted with each CTE on its own indented block. CASE/WHEN/THEN/ELSE/END blocks are indented to show their structure clearly.