SQL Formatter
Beautify and format SQL queries with proper indentation and consistent keyword capitalization. Supports SELECT, INSERT, UPDATE, DELETE, CREATE, and more.
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
- Paste your SQL query (minified or single-line) into the input area.
- Choose the SQL dialect if applicable (MySQL, PostgreSQL, etc.).
- Click Format β the indented, readable SQL appears in the output.
- 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.