SQL Beautifier turns minified or messy SQL into a clean, indented query with each clause on its own line. Paste your query, choose the style, click the button and copy the result. It is free and runs in your browser.
SELECT customer_name, COUNT(order_id) AS num_orders FROM orders JOIN customers ON orders.customer_id = customers.id WHERE order_date >= '2023-01-01' AND status = 'shipped' GROUP BY customer_name HAVING COUNT(order_id) > 5 ORDER BY num_orders DESC;
SELECT customer_name, COUNT(order_id) AS num_orders FROM orders JOIN customers ON orders.customer_id = customers.id WHERE order_date >= '2023-01-01' AND status = 'shipped' GROUP BY customer_name HAVING COUNT(order_id) > 5 ORDER BY num_orders DESC;
Bookmark: press Ctrl+D (Windows) or Cmd+D (Mac) to save this tool.
An SQL beautifier, also called an SQL formatter, adds line breaks and indentation to SQL. A long query written on one line becomes easy to read, check and edit.
The tool changes only whitespace and, if you want, the case of keywords. Each main clause starts on its own line, each selected column gets its own line, conditions in WHERE are lined up, and subqueries, CASE expressions and CREATE TABLE columns are indented. Strings, names and comments stay as you wrote them.
It does not run or check your query. Use it before you review a long query, share it with a teammate or paste it into documentation.
Each clause starts on a new line, and columns and conditions are indented. These examples use a 2 space indent and uppercase keywords.
| Before | After |
|---|---|
select id,name from users order by name | SELECT id, name FROM users ORDER BY name |
select * from users where age>18 and city='Paris' | SELECT * FROM users WHERE age > 18 AND city = 'Paris' |
insert into users(name,age) values('Ann',30) | INSERT INTO users (name, age)
VALUES
('Ann', 30) |
update users set age=31 where id=1 | UPDATE users SET age = 31 WHERE id = 1 |
Reading long queries from logs or ORMs, reviewing a colleague's query, tidying SQL before you share it and keeping the same style across a project.
The tool does not validate SQL, and it handles common SQL best. Stored procedures and other database-specific syntax may look basic. Keep a copy of your original query, or use Undo right after formatting.
To format other code or data, try the JSON, JavaScript, HTML or CSS beautifiers.
An SQL beautifier takes minified or messy SQL and adds line breaks and indentation, so each clause, column and condition is easy to read. It is also called an SQL formatter.
Paste your query into the box, choose the indent size and keyword style, then click Beautify SQL. The formatted query replaces the text in the box. Click Copy to use it, or Undo to go back.
No. The tool only changes whitespace and, if you choose, the case of SQL keywords. Strings, quoted names, numbers, comments and your table and column names are kept as they are.
It sets the case of SQL keywords and common functions such as SELECT, WHERE and COUNT. Choose Uppercase, lowercase, or Keep as is. Unquoted keywords are not case sensitive in SQL, so this changes how the query looks, not how it runs.
Each main clause, such as SELECT, FROM, WHERE, GROUP BY and ORDER BY, starts on its own line. Selected columns go on separate lines, AND and OR conditions in WHERE are indented, a JOIN and its ON condition share a line, and subqueries and CASE expressions are indented.
It is made for common SQL as used in MySQL, PostgreSQL, SQL Server, SQLite and Oracle. Features that belong to one database, such as stored procedures or procedural blocks, may be formatted in a basic way.
Beautifying adds line breaks and indentation to make a query readable. Minifying removes them to make it shorter. Use a beautifier when you want to read or edit a query.
No. It is a formatter, not a validator, and it never runs your query or connects to a database. If your SQL has a mistake, the tool formats what it can but does not report the error.
Yes. It is free, needs no account and runs in your browser, so your queries are not uploaded to a server.
Last updated: 26 October 2026