Format and pretty-print SQL with keyword casing

Pretty-print SQL with keyword casing.

Paste a SQL statement, pick an indent and keyword case, and copy the pretty-printed output. Pure browser, no upload.

Input

Formatted

SELECT
  id, name, email
FROM
  users
  JOIN orders
  ON users.id = orders.user_id
WHERE
  status = 'active'
ORDER BY
  created_at DESC
LIMIT
  10;

Formatting SQL so it can be read

SQL copied from an application log, an ORM debug message or a colleague's chat arrives as one long line. Before you can review it, spot a missing condition or explain it to someone, it needs line breaks and indentation that show its structure: what is selected, from where, under which conditions.

This formatter puts each main clause on its own line, indents the clause bodies, keeps joins and conditions readable and writes keywords in upper or lower case, all in your browser.

How to use it

  1. Paste the SQL statement into the input box.
  2. Choose the indent width and whether keywords are written in UPPER or lower case.
  3. Read the formatted query on the right.
  4. Copy it into your editor, code review or documentation.

Example: a one-line query

Input
select id, name from users where active = 1 and age > 30 order by name
Output
SELECT
  id, name
FROM
  users
WHERE
  active = 1
  AND age > 30
ORDER BY
  name

Each condition joined with AND starts its own line, so adding, removing or commenting out a condition is a one-line change.

Why formatting matters

A consistent layout turns SQL review into scanning. Clauses always appear in the same order, SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY, LIMIT, and one condition per line makes a forgotten filter or an accidental OR visible at a glance. Version control diffs also get smaller, because a change touches one line instead of rewriting a long one.

Upper-case keywords are a convention, not a requirement: databases treat select and SELECT the same. Many teams prefer upper case so keywords stand out from table and column names.

What the formatter changes and what it keeps

It only changes whitespace and keyword case. Table names, column names, string literals and values are left exactly as written, so the formatted query runs the same way. It is a pretty-printer, not a validator: it does not check that tables exist or that the syntax is valid for your database.

The layout covers SELECT, INSERT, UPDATE and DELETE statements with joins and conditions. Very complex queries with nested subqueries or vendor-specific syntax are formatted on a best-effort basis; review the result before you rely on it.

Questions

Does it work for MySQL, PostgreSQL and SQL Server?

Yes for the common syntax all of them share. Vendor-specific keywords are kept but may not get their own line.

Is it safe to paste queries with real data?

The query never leaves your browser. Still, consider removing personal data from queries you share with others.

Can it fix a broken query?

No. It only changes layout. A clean layout often makes the error easy to find, though, such as a missing comma between two columns.