// tool_07

SQL Formatter & Beautifier

Paste raw or minified SQL and get clean, readable output instantly — client-side, nothing leaves your browser.

// updated April 2026
Input SQL
Formatted Output
Ready
chars: 0
lines: 0
statements: 0
// quick examples

// why format sql?

Raw or minified SQL is hard to read, review, and debug. Proper formatting with consistent indentation, keyword casing, and clause alignment makes queries easier to understand and maintain.

Formatted SQL also makes code reviews more effective and helps catch logic errors like missing JOIN conditions or incorrect WHERE clauses. Read our SQL formatting best practices guide and how to format SQL queries.

// sql formatting conventions

Keywords uppercase — writing SELECT, FROM, WHERE in uppercase is the most widely used convention and makes keywords instantly distinguishable from identifiers.

One clause per line — each major clause (SELECT, FROM, WHERE, JOIN) starts on a new line for readability.

Indent subqueries — subqueries and CTEs should be indented to show nesting clearly.

// frequently asked questions
How do I format a SQL query online?
Paste your SQL into the input above and click Format. The formatter handles SELECT, INSERT, UPDATE, DELETE, JOIN, GROUP BY, ORDER BY, CTEs, and window functions. See our full guide: how to format SQL queries.
What is SQL beautification?
SQL beautification (also called SQL formatting or pretty-printing) transforms compressed or inconsistently formatted SQL into clean, readable code with consistent indentation, keyword casing, and clause alignment. It does not change the query logic — only the presentation.
How do I format SQL in VS Code?
Install the "SQL Formatter" extension by adpyke or the "Prettier" extension with SQL support. Then use Shift+Alt+F (Windows) or Shift+Option+F (Mac) to format. Alternatively, paste your SQL here and copy the result back. See our guide: SQL formatting best practices.
Does this SQL formatter support CTEs and window functions?
Yes — this formatter handles WITH clauses (CTEs), window functions with OVER (PARTITION BY ... ORDER BY ...), subqueries, and all standard DML statements. Load the "CTE" or "Window function" snippet above to see examples.
What databases does this SQL formatter support?
The formatter supports standard SQL syntax compatible with MySQL, PostgreSQL, SQLite, SQL Server (T-SQL), and Oracle. Dialect-specific syntax like TOP (SQL Server) and ROWNUM (Oracle) are recognised as keywords.