Home / Tools / SQL formatter

SQL Formatter: Beautify and Indent SQL Queries Online

Paste a SQL query and get readable, indented code with keywords in capitals. Handles joins, subqueries, grouping and updates. Runs in your browser.

Paste your SQL and press Beautify. Clauses start on new lines, columns are listed one per line, joins and conditions are indented, CASE expressions are laid out line by line, CREATE TABLE puts one column on each line, and subqueries and WITH clauses are nested. Keywords can be turned to capitals. Stored procedures, functions and triggers (MySQL DELIMITER blocks and PostgreSQL $$ bodies) are laid out with IF, WHILE, LOOP and CASE indented.

What it does

Example

Before

select u.id,u.name,count(o.id) as orders from users u left join orders o on o.user_id=u.id where u.active=1 and u.age>18 group by u.id,u.name order by orders desc limit 10;

After

SELECT
  u.id,
  u.name,
  count(o.id) AS orders
FROM users u
  LEFT JOIN orders o ON o.user_id = u.id
WHERE u.active = 1
  AND u.age > 18
GROUP BY
  u.id,
  u.name
ORDER BY orders DESC
LIMIT 10;

Frequently asked questions

Which SQL dialects does it support?
Everyday MySQL, PostgreSQL, SQLite and SQL Server queries (SELECT, INSERT, UPDATE, DELETE, WITH, CASE, CREATE TABLE), plus MySQL stored procedures with DELIMITER and PostgreSQL functions with $$ bodies. It lays out the code but does not check it, and unusual vendor syntax (T-SQL TRY/CATCH, Oracle PL/SQL packages) is kept on single lines rather than restructured.
Does it change what the query does?
No. Only spacing, line breaks and keyword case change. Strings and quoted names are kept as written.
Why are my table names not capitalised?
Only SQL keywords are changed. Table and column names keep their case.
Can it handle several statements?
Yes. Statements separated by semicolons are formatted one after another.

Runs in your browser. Nothing you type is sent to this site. Updated 2026-10-11.

More tools

Code formatters

CSS beautifier CSS minifier HTML beautifier HTML minifier JavaScript beautifier JavaScript minifier JSON formatter YAML formatter XML formatter Markdown preview

Converters

Base64 encoder and decoder URL encoder and decoder Unix timestamp converter CSV to JSON JSON to CSV HTML entity encoder and decoder Number base converter Time zone converter JSON to TypeScript XML to JSON HTML to Markdown Date difference calculator

Text tools

Regex tester Remove duplicate lines Lorem ipsum generator Word counter Case converter Text diff checker

Color and images

Color converter Contrast checker Image to Base64 Image resizer

Network

Subnet calculator Download time calculator Common ports list CIDR to IP range IPv6 address expander and compressor MAC address formatter curl command builder

Server and files

Cron expression explainer chmod calculator HTTP status codes

Encoding and security

Password generator UUID generator Hash generator JWT decoder QR code generator Password strength checker Wi-Fi QR code generator