SQLFormatter
FormatterConvertPricingDocsGet Pro
Formatter & beautifier · T-SQL

Format & beautify T-SQL SQL online

Format and beautify T-SQL SQL: consistent indentation, aligned clauses, uppercase keywords — and minified one-liners expanded back into readable code.

1Paste your T-SQL query into the editor.
2Press Format — or ⌘↵.
3Copy clean, highlighted SQL.
Open formatter
before
select top 20 [OrderId],[CustomerName],isnull([Total],0) as Total from [dbo].[Orders] where [Status]='shipped' order by [CreatedAt] desc;
T-SQL
SELECT
  TOP 20 [OrderId],
  [CustomerName],
  isnull([Total], 0) AS Total
FROM
  [dbo].[Orders]
WHERE
  [Status] = 'shipped'
ORDER BY
  [CreatedAt] DESC;

Why format T-SQL?

T-SQL (SQL Server) has its own dialect: TOP instead of LIMIT, [bracket]-quoted identifiers, ISNULL, and statement terminators SSMS is picky about. The formatter follows Transact-SQL rules so bracketed names and TOP clauses format correctly.

Especially useful for queries copied out of SSMS or Profiler traces that need to go back in clean.

Beautify minified T-SQL SQL

Nested subqueries and EXISTS clauses are where T-SQL gets hard to read — and SSMS often hands them to you as one dense line. Beautifying indents each subquery so its boundaries are clear, bracketed [identifiers] and all.

A properly indented T-SQL query is also far easier to paste back into SSMS and step through, instead of squinting at a wall of brackets.

minified
SELECT [c].[Name],(SELECT COUNT(*) FROM [dbo].[Orders] o WHERE o.CustomerId=c.Id)AS Orders FROM [dbo].[Customers] c WHERE EXISTS(SELECT 1 FROM [dbo].[Orders] o2 WHERE o2.CustomerId=c.Id AND o2.Total>500)ORDER BY Orders DESC;
T-SQL · beautified
SELECT
  [c].[Name],
  (
    SELECT
      COUNT(*)
    FROM
      [dbo].[Orders] o
    WHERE
      o.CustomerId = c.Id
  ) AS Orders
FROM
  [dbo].[Customers] c
WHERE
  EXISTS (
    SELECT
      1
    FROM
      [dbo].[Orders] o2
    WHERE
      o2.CustomerId = c.Id
      AND o2.Total > 500
  )
ORDER BY
  Orders DESC;

Frequently asked questions

Does the formatter understand T-SQL-specific syntax?

Yes. The query is parsed against T-SQL grammar rather than generic SQL, so T-SQL-only constructs survive formatting: TOP, [bracketed] names, ISNULL — SSMS-ready.

What is the difference between formatting and beautifying T-SQL SQL?

Nothing — they are two names for the same operation. "Format" usually describes tidying SQL you wrote yourself; "beautify" usually describes expanding a minified or ORM-generated one-liner into readable lines. This page does both, with a worked example of each above.

Is my SQL uploaded anywhere?

No. Formatting runs entirely in your browser — the query never leaves your machine and nothing is stored on a server.

Is the T-SQL formatter free?

Yes: free, no account, no usage limit. Only the optional AI features — explain, optimize and dialect conversion — require signing in.

All SQL formatters & beautifiers

Format PostgreSQLFormat MySQLFormat T-SQLFormat SQLiteFormat BigQueryFormat OracleFormat SnowflakeFormat Redshift