SQL Formatter

Format and prettify SQL queries -- free, private, runs entirely in your browser

Input SQL
Formatted Output
1

Your SQL never leaves your browser. No server, no logging, no account.

Why Format SQL?

Raw SQL written under deadline pressure or copied from logs is often a wall of text with inconsistent casing, no indentation, and keywords crammed onto the same line as their clauses. Formatted SQL is dramatically easier to read, debug, and maintain.

SQL Formatting Conventions

There is no single standard, but these conventions are widely followed and what this tool applies:

Example -- unformatted:

select u.id,u.name,o.total from users u join orders o on u.id=o.user_id where o.total>100 and u.active=1 order by o.total desc limit 10

Example -- formatted:

SELECT
  u.id,
  u.name,
  o.total
FROM users u
JOIN orders o
  ON u.id = o.user_id
WHERE o.total > 100
  AND u.active = 1
ORDER BY o.total DESC
LIMIT 10

Supported SQL Statements

This formatter handles the most common SQL constructs found in application code and data work:

Frequently Asked Questions

Does this validate SQL?

No. The formatter only adjusts whitespace, indentation, and keyword casing. It does not parse the SQL grammar or check for syntax errors. If your query has a typo or a missing parenthesis, it will be formatted as-is without any warning about the syntax problem.

Which SQL dialects are supported?

The tool supports Standard SQL and extends keyword recognition for MySQL and PostgreSQL when you select those dialects. The dialect setting primarily affects which words are treated as keywords for highlighting and casing -- the core formatting logic (clause placement, indentation) is the same across all three.

Is my SQL sent to a server?

No. All formatting runs in JavaScript directly in your browser tab. Your SQL query never leaves your machine. There is no backend server processing your queries, no usage logging, and no account required.