SQL Formatter and Beautifier
Paste a SQL query to format it into clean, readable lines. Major clauses like SELECT, FROM, WHERE and JOIN go on their own lines, the column list is indented one item per line, and keywords are uppercased so queries are easy to scan and review.
How to format SQL
- Paste your SQL query into the editor.
- Toggle uppercase keywords on or off to match your style.
- Copy the formatted query straight into your editor or pull request.
Examples
A SELECT with a filter
select a, b from users where id = 1 and active = 1
SELECT a, b FROM users WHERE id = 1 AND active = 1
A JOIN query
select u.id from users u inner join orders o on o.user_id = u.id
SELECT u.id FROM users u INNER JOIN orders o ON o.user_id = u.id
Frequently asked questions
What does the SQL formatter do?
It rewrites a query with consistent line breaks and indentation. Each major clause (SELECT, FROM, WHERE, GROUP BY, ORDER BY, HAVING, LIMIT and the JOIN variants) starts a new line, the SELECT column list is indented one item per line, and AND or OR conditions break onto their own indented lines. Keywords are uppercased by default.
Which SQL dialects are supported?
It works on standard SQL and the common dialects that share that syntax, including PostgreSQL, MySQL, SQLite, SQL Server and others. It formats the structure of a query rather than enforcing any one vendor's rules, so most everyday SELECT, INSERT, UPDATE, DELETE and DDL statements format cleanly.
Does it validate or run my SQL?
No. The formatter only reshapes whitespace and keyword casing. It does not check that your query is valid, connect to a database, or run anything. Your SQL is rearranged exactly as written, including any syntax errors.
Are my strings and identifiers left alone?
Yes. Text inside single quotes, double quotes or backticks is preserved character for character, including any words that look like keywords. Only keywords outside of quotes are re-cased, and column and table names keep their original casing.
Is my query private?
Yes. Formatting happens entirely in your browser. Nothing you paste is uploaded, logged or stored on a server.
What are the limitations?
This is a lightweight structural formatter, not a full SQL parser. Very deeply nested subqueries, vendor-specific syntax and unusual operators may format more simply than a dialect-aware tool would. For everyday queries it produces clean, consistent output you can drop straight into code review.
Related tools
JSON Formatter
Format, validate and minify JSON online. Pretty-print with custom indentation, sort keys and catch syntax errors. Runs in your browser.
Diff Checker
Compare two texts or files side by side or unified, with word and character highlighting, ignore whitespace or case, collapse unchanged, and .diff export.
.env to JSON
Convert a .env file to JSON, or JSON back to .env. Parses KEY=value lines, comments, quotes and export. Runs entirely in your browser.
ASCII Table
Full ASCII table for all 128 codes with decimal, hex, octal and binary values, character names and descriptions. Search by code, hex or character.
Aspect Ratio Box Generator
Generate CSS for a responsive aspect-ratio container. Use the modern aspect-ratio property or the padding-top fallback, then copy the ready code.
Aspect Ratio Calculator
Calculate aspect ratios fast. Enter a ratio like 16:9 and one dimension to get the other, or enter width and height to simplify the ratio.