SQL Formatter
Format and beautify SQL queries with consistent keyword casing and indentation.
Designed to run in your browser. See the privacy policy.
About SQL Formatter
This SQL formatter turns a long, single-line or messy query into readable SQL. Paste a query and it puts each major clause (SELECT, FROM, WHERE, JOIN, ON, GROUP BY, ORDER BY, HAVING, LIMIT, UNION, INSERT INTO, VALUES, UPDATE, SET, DELETE FROM) on its own line, pushes AND and OR onto indented lines, and indents by two spaces inside parentheses. It is a quick way to format an SQL query online before reading it, reviewing it or pasting it into a ticket.
It is a lightweight, heuristic SQL beautifier rather than a full parser. There is no dialect setting and it does not validate syntax, so it treats MySQL, PostgreSQL, SQL Server and SQLite queries the same way and will happily format a query that would fail to run. The formatting runs in your browser as you type.
How to use
- Paste your query into the sql input box.
- Leave Uppercase keywords switched on to capitalise recognised keywords, or switch it off to keep your original casing.
- Read the result in the formatted sql panel; it updates as you type or edit.
- Use copy to put the formatted SQL on your clipboard, or download to save it as formatted.sql.