πŸ—ƒοΈ

SQL Formatter

Beautify and format SQL queries with proper indentation and consistent keyword capitalization. Supports SELECT, INSERT, UPDATE, DELETE, CREATE, and more.

Input SQL
Formatted SQL

About SQL Formatter

SQL Formatter takes messy, single-line, or inconsistently formatted SQL and produces clean, readable output. It places each major clause (SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY, HAVING) on its own line with consistent indentation, making queries much easier to read and debug.

Supported Statements

  • SELECT β€” Formats column lists, FROM, JOIN, WHERE, GROUP BY, HAVING, ORDER BY, LIMIT.
  • INSERT β€” Formats INSERT INTO ... VALUES.
  • UPDATE β€” Formats SET clauses and WHERE conditions.
  • DELETE β€” Formats DELETE FROM with WHERE.
  • CREATE TABLE β€” Formats column definitions.

How to Use

  1. Paste your SQL query (minified or single-line) into the input area.
  2. Choose the SQL dialect if applicable (MySQL, PostgreSQL, etc.).
  3. Click Format β€” the indented, readable SQL appears in the output.
  4. Click Copy to copy the formatted SQL.

How It Works

The tool tokenizes the SQL into keywords, identifiers, operators, and literals, then rebuilds the query with consistent indentation for nested clauses (SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY). Keywords are uppercased for readability.

Example

Input: select u.name,o.total from users u join orders o on u.id=o.user_id where o.total>100 order by o.total desc
Output: properly indented multi-line SQL with uppercased keywords, each clause on its own line.

FAQ

No β€” this tool formats SQL for readability but does not validate syntax or check against a specific database dialect. It works with standard SQL and common extensions.
No. All formatting runs entirely in your browser. Your SQL queries are never transmitted anywhere.