SQLFormatter
FormatterConvertPricingDocsGet Pro
Beautifier · T-SQL

Beautify T-SQL SQL online

Beautify minified, single-line T-SQL SQL into clean, readable, properly indented queries. Turn crushed output from logs, ORMs or dbt into something you can read, diff and review.

1Paste your T-SQL query into the editor.
2Press Format — or ⌘↵.
3Copy clean, highlighted SQL.
Open formatter
before
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
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;

Why beautify T-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.

All SQL formatters & beautifiers

Format PostgreSQLBeautify PostgreSQL
Format MySQLBeautify MySQL
Format T-SQLBeautify T-SQL
Format SQLiteBeautify SQLite
Format BigQueryBeautify BigQuery
Format OracleBeautify Oracle
Format SnowflakeBeautify Snowflake
Format RedshiftBeautify Redshift