🔧

SQL Formatter

Format SQL queries with proper indentation and keyword capitalization.

How to Use

  1. Paste your SQL query into the input area — the formatter accepts SELECT, INSERT, UPDATE, DELETE, CREATE TABLE, and complex queries with joins, subqueries, CTEs, and window functions.
  2. Choose your formatting preferences: select a SQL dialect (Standard SQL, MySQL, PostgreSQL, or TSQL), set your indent size (2 or 4 spaces), and choose keyword casing (UPPERCASE, lowercase, or capitalize).
  3. Click Format to beautify your SQL, then copy the formatted result. All keywords are properly capitalized, indentation follows nesting depth, and comma placement is standardized for maximum readability.

Frequently Asked Questions

Which SQL dialects are supported?
The formatter supports Standard SQL (ANSI/ISO), MySQL, PostgreSQL, and TSQL (Microsoft SQL Server). Each dialect handles quoting styles, identifier escaping, and dialect-specific keywords differently. Choose the one matching your database for best results.
Can it handle complex queries with subqueries and CTEs?
Yes — the formatter understands nested subqueries, Common Table Expressions (WITH clauses), JOIN chains, UNION/INTERSECT/EXCEPT, window functions, and CASE expressions. Each level of nesting gets its own indentation to make complex logic easy to follow.
Why format SQL keywords in uppercase?
Uppercase keywords (SELECT, FROM, WHERE) improve readability by visually separating SQL commands from identifiers like table and column names. This convention makes it easier to scan queries and spot structural issues. You can also choose lowercase or capitalize if you prefer a different style.