SQL Formatter & Beautifier Online

Paste mangled SQL, get readable SQL. Keywords capitalized, clauses on their own lines, parentheses indented — all locally in your browser.

Embed this tool on your website / blog No code required · Copy and paste
HTML Embed Code (iframe):
<iframe src="https://lucentool.com/sql-formatter" width="100%" height="650" style="border:1px solid #e5e0d8;border-radius:12px;max-width:850px;width:100%;" frameborder="0"></iframe>
<div style="font-size:12px;color:#78716c;margin-top:6px;font-family:sans-serif;">Powered by <a href="https://lucentool.com/sql-formatter" target="_blank" style="color:#c85a32;text-decoration:none;">Lucentool - SQL Formatter & Beautifier Online</a></div>

What this formatter does

It tokenizes your SQL and rebuilds it with consistent rules: clause keywords (SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY, LIMIT, JOIN, ON, SET, VALUES…) start new indented lines; commas and operators get spacing; strings and comments are preserved untouched; parentheses increase indentation.

What it doesn't do

Formatting conventions

Clause-first style: each main clause on its own line at the same level, sub-queries indented one level, AND/OR aligned under their WHERE. This matches the style used in most open-source projects and is easy to read in diffs.

Example — input: select u.id,u.name from users u where u.active=true order by u.id becomes:

SELECT u.id,
       u.name
FROM users u
WHERE u.active = true
ORDER BY u.id;