SQL Formatter & Beautifier

Make long or minified SQL readable, with consistent indentation and keyword case.

100% Client-Side Processing — your data never leaves this browser. Works offline. How it works

0 lines • 0 bytes Ready
Tip: drop a file anywhere on the editor
Input
Paste, type or drop a file
1
Result
Updates as you type
// Output will appear here…
About this tool

How the SQL Formatter works

Format and beautify SQL queries: one clause per line, indented column lists, joins and subqueries, and uppercase keywords. Works for MySQL, PostgreSQL and more.

How to use the SQL Formatter

  1. Paste one or more SQL statements.
  2. Choose the indentation and keyword case.
  3. Copy the formatted SQL back into your editor.

SQL Formatter example

Input
select id, name from users where active = 1 and city = 'Pune' order by name;
Result
SELECT
  id,
  name
FROM users
WHERE active = 1
  AND city = 'Pune'
ORDER BY
  name;

When to use it

  • Reading queries copied from logs or ORM debug output.
  • Cleaning SQL before a code review.
  • Making long reports and analytics queries maintainable.

Tip: Format queries before committing them: consistent layout makes diffs much easier to review.

Readable layout

SELECT lists, GROUP BY and ORDER BY items go one per line; FROM, WHERE, JOINs and LIMIT each start a new line.

Subqueries and joins

Nested SELECTs are indented inside their parentheses and ON conditions sit under their JOIN.

Keyword case

UPPERCASE, lowercase or keep keywords as typed; identifiers and strings are never changed.

Comments preserved

-- and /* */ comments stay in place on their own lines.

FAQ

Common questions

Does formatting change what the query does?

No. Only whitespace and keyword case change; strings, identifiers and values are left exactly as written.

Which SQL dialects work?

Standard SQL plus common MySQL, PostgreSQL, SQLite and SQL Server syntax, including backtick and bracket identifiers and :: casts.

Can it format several statements?

Yes. Statements separated by semicolons are formatted one after another with a blank line between them.

Is my query uploaded?

No. Formatting runs in your browser, so queries containing customer data stay private.