Skip to content

T-SQL Formatter

Format T-SQL for SQL Server and Azure SQL with rules for [bracket] identifiers, N'' Unicode strings, #temp tables, @variables and GO batch separators. CROSS APPLY and OUTER APPLY start new lines, OUTPUT and FOR JSON are kept as clauses and BEGIN TRANSACTION never opens a block by mistake. Unclosed strings and parentheses are reported with line and column for database developers.

Reset

Frequently asked questions

Which T-SQL syntax is understood?

Identifiers in [square brackets] with ]] escapes or double quotes, N'' Unicode strings, #temp and ##global temporary tables, @variables and @@ system functions are recognized. Static method calls such as geography::Point stay intact too.

How are GO batch separators handled?

A line that contains only GO, optionally with a repeat count such as GO 5, ends a batch. It stays on its own line and each batch is formatted separately.

Which T-SQL clauses are supported?

CROSS APPLY and OUTER APPLY start new lines like joins. OUTPUT, OPTION, FOR XML and FOR JSON are kept as their own clauses next to the standard ones.

Can it format stored procedures?

Yes. BEGIN and END blocks, BEGIN TRY and BEGIN CATCH, IF and ELSE, and WHILE loops are indented. BEGIN TRANSACTION and BEGIN TRAN are treated as statements, not as the start of a block.

Does it support MERGE?

Yes. WHEN MATCHED, WHEN NOT MATCHED BY TARGET and WHEN NOT MATCHED BY SOURCE branches start new lines.

Are comments kept?

Yes. -- line comments and /* block comments */ stay in place. Multi-line block comments are re-indented to their new position.

Does it change keyword case?

No. Keywords and identifiers keep the case you wrote. Only whitespace and line breaks change.

Which errors are detected?

Unclosed strings, bracket or quoted identifiers and block comments, and unbalanced parentheses, each with line and column. The tool does not connect to SQL Server or validate object names.

How large can the input be?

Up to 1 MB per request and 128 KB per statement or batch. Statements are separated by blank lines.

Can I choose the indentation, and is my SQL stored?

You can use 2 or 4 spaces or tabs. Your script is formatted in memory only and never saved.

About OneClick Pro

OneClick Pro is a free collection of more than 150 web tools for everyday work: converting images and units, formatting and validating code, checking domains and SEO, and working with text, dates and numbers. Every tool runs without registration or subscription, and what you enter is only used to calculate your result and is never stored. Use it as a quick toolbox for one-off tasks, or bookmark the tools you rely on every day.