SQL Server (T-SQL) Formatter
Format T-SQL for Microsoft SQL Server. Handles TOP, schema-qualified names and bracket identifiers. Paste your query and beautify it online.
Part of the free SQL Formatter. Runs in your browser — nothing is uploaded.
SQL Server (T-SQL) Formatter
T-SQL has its own habits: SELECT TOP, dbo-qualified names and [bracketed] identifiers. With the SQL Server dialect selected, your stored-procedure snippets and ad-hoc queries are laid out clearly for review.
Worked example: TOP and schema-qualified tables in T-SQL
Input
select top 10 e.EmployeeID, e.LastName, d.DepartmentName from dbo.Employees e inner join dbo.Departments d on d.DepartmentID = e.DepartmentID where e.HireDate >= '2020-01-01' order by e.HireDate desc;
Formatted T-SQL
SELECT TOP 10 e.EmployeeID, e.LastName, d.DepartmentName FROM dbo.Employees e INNER JOIN dbo.Departments d ON d.DepartmentID = e.DepartmentID WHERE e.HireDate >= '2020-01-01' ORDER BY e.HireDate DESC;
Practical tip
Keep GO batch separators on their own line when pasting scripts from SSMS, then format each batch separately for the cleanest result.
How to use this SQL Formatter
- 1Use the live tool above — it runs entirely in your browser and never uploads your data.
- 2Paste the sample from the worked example, or use your own input.
- 3Copy the result, then adapt the same steps in your editor, script, or pipeline.
SQL Server (T-SQL) Formatter FAQs
Does it support SELECT TOP?
Yes. TOP n, schema-qualified names such as dbo.Employees and bracketed identifiers are handled with the SQL Server (T-SQL) dialect.
Can it format stored procedures?
It formats common statements inside procedures. Very procedural T-SQL with complex control flow may need manual touch-ups.
More SQL Formatter pages
- Format SQL Query OnlineFormat SQL queries online with uppercase keywords and clean indentation. Paste a one-line query and get readable SQL instantly. Free and private.
- PostgreSQL Formatter OnlineFormat PostgreSQL queries with dialect support for JSONB operators, casts and Postgres functions. Paste SQL, choose PostgreSQL and beautify.
- MySQL Query FormatterFormat MySQL queries online with backtick identifiers and MySQL functions handled correctly. Paste your query, pick MySQL and beautify it.
- Beautify SQL JOIN QueriesFormat multi-table SQL JOIN queries so every join and ON condition sits on its own line. Paste your query and read the relationships clearly.
- Format Long SQL SELECT StatementsFormat SELECT statements with dozens of columns. Each column lands on its own line so wide queries are easy to read, edit and review.
- BigQuery SQL FormatterFormat Google BigQuery SQL with backtick project.dataset.table names. Choose the BigQuery dialect and beautify analytics queries online.
- Snowflake SQL FormatterFormat Snowflake SQL with database.schema.table names and Snowflake functions. Pick the Snowflake dialect and beautify queries online.
- Format SQL INSERT StatementsFormat multi-row INSERT INTO statements so each VALUES tuple sits on its own line. Easier to review seed data and migrations.
- SQL CTE FormatterFormat SQL queries that use WITH common table expressions. Each CTE is indented clearly so multi-step queries are easy to follow. Free and private.