SQL Formatter

A T-SQL formatter that formats statements carrying comments instead of skipping them — and hands back exactly what you pasted, with a reason, rather than guessing when it cannot.

Formatted
Formatted SQL appears here.

It formats statements that carry comments, which most formatters skip — so the documented scripts stop being the ones that never get formatted. Every note stays with the code it was written about.

It checks its own work and refuses rather than guessing. If the SQL does not come back token for token with every comment intact, you get back exactly what you pasted, and a reason.

The layout follows the SQL Server documentation (Microsoft publishes no official T-SQL style guide): keywords at the margin, four-space continuations, trailing commas, and BEGIN/END blocks indenting what they contain. It never adds a token, so it will not insert the semicolons Microsoft recommends.

Things that only look like comments are handled and tested: '-- in a string', [weird--column], 'it''s', and T-SQL's genuinely nested /* /* */ */.

Private by design: everything runs in your browser. The SQL you paste is never uploaded, logged, or stored anywhere.