SQL Formatter

Format and beautify SQL queries with consistent keywords and indentation.

About this tool

Paste a SQL query to reformat it with consistent keyword capitalization, one clause per line, and indented column lists — turning a dense one-liner into something you can actually read and review.

It works on standard SQL syntax (SELECT, INSERT, UPDATE, DELETE, JOINs, WHERE/AND/OR, GROUP BY, ORDER BY, HAVING) and runs entirely in your browser — nothing is uploaded or executed.

Example

Input
select id, name, email from users u join orders o on o.user_id=u.id where u.active=1 and o.total>100 order by o.created_at desc;
Formatted
SELECT
  id,
  name,
  email
FROM
  users u
  JOIN orders o ON o.user_id = u.id
WHERE
  u.active = 1
  AND o.total > 100
ORDER BY
  o.created_at DESC;

Frequently asked questions

Does this validate my SQL or connect to a database?
No — it only reformats the text you paste for readability. It doesn't parse a specific database dialect's grammar, execute anything, or check whether the query is valid.
Will it work with any SQL dialect?
The formatter recognizes standard ANSI SQL keywords common to MySQL, PostgreSQL, SQLite, and SQL Server. Dialect-specific syntax should pass through unchanged, though very unusual formatting may not break exactly where you'd expect.
Does it change my query's meaning?
No — only whitespace, line breaks, and keyword casing are changed. Identifiers, string literals, and values are left exactly as written.