Free online text tool

SQL Beautifier

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.

SQL Beautifier Tool

0Character Count
0Character Count (without spaces)
0Word Count
0Sentence Count
0Paragraph Count
0Line Count

SQL Beautifier Example

Before
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;
After
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.

Suggest a New ToolProvide Feedback on This Tool

What is an SQL beautifier?

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.

SQL beautifier examples

Each clause starts on a new line, and columns and conditions are indented. These examples use a 2 space indent and uppercase keywords.

BeforeAfter
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

How to beautify SQL

  1. 1
    Paste your SQL
    Paste minified or messy SQL into the box, or import a text file.
  2. 2
    Choose the style
    Pick the indent size and whether keywords are uppercase, lowercase or left as they are.
  3. 3
    Click Beautify SQL
    The query in the box is formatted at once. Use Undo if you change your mind.
  4. 4
    Copy it
    Click Copy and paste the formatted query into your editor.

When to use an SQL beautifier

Good for

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.

Check first

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.

Other tools

To format other code or data, try the JSON, JavaScript, HTML or CSS beautifiers.

SQL beautifier FAQ

What is an SQL beautifier?

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.

How do I beautify SQL?

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.

Does it change what my query does?

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.

What does the keyword option do?

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.

How is the query laid out?

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.

Which databases does it work with?

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.

What is the difference between beautifying and minifying SQL?

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.

Does it check my SQL for errors or run it?

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.

Is this tool free and is my SQL private?

Yes. It is free, needs no account and runs in your browser, so your queries are not uploaded to a server.

Looking for more text tools?

Browse Formatter Tools

Last updated: 26 October 2026