SQL Server Formatter

Beautify T-SQL for Microsoft SQL Server and Azure SQL, including [bracketed] names, TOP and @variables.

Runs in your browser

SQL

Formatted SQL

Your SQL is processed in this browser tab and never uploaded.

How to use the SQL Server Formatter

  1. Paste your SQL Server query into the editor, or press Sample to load an example.
  2. The SQL Server dialect is already selected, so dialect-specific syntax is parsed correctly.
  3. Press Format (Ctrl + Enter). Pick indentation and keyword case in the options.
  4. Copy the result or download it as a .sql file.

Example

A SQL Server query before formatting
Input
declare @since date = '2024-01-01'; select top (10) c.[Customer Name], sum(o.[Total Due]) as total from dbo.Customers c inner join dbo.[Order Details] o on o.CustomerId = c.Id where o.OrderDate >= @since group by c.[Customer Name] order by total desc;

SQL Server syntax this formatter understands

  • Square-bracket identifiers like [Order Details] are preserved exactly.
  • Local @variables and global @@ variables are recognised as names, not operators.
  • SELECT TOP (n), OUTPUT, MERGE and CROSS APPLY are laid out as their own clauses.
  • GO batch separators are kept on their own line.

What it does

SQL Server-aware parsing
Uses the SQL Server grammar from the open-source sql-formatter library, so syntax that is specific to SQL Server is handled correctly.
Keyword case control
Keep the original case, or convert all keywords to UPPERCASE or lowercase as you format.
Private by design
Formatting happens on your device. Nothing you paste leaves the browser.

Frequently asked questions

Is my SQL Server query sent to a server?

No. The formatter runs entirely in your browser. Your query is never uploaded, logged or stored, so it is safe to paste production SQL.

Will formatting change what my query does?

No. Only whitespace, line breaks and (if you choose) keyword case change. String literals, quoted identifiers and comments are kept exactly as written.

Does it validate my query?

The formatter has to parse your query, so badly broken SQL produces an error with its location. It does not check that tables or columns exist, and some invalid queries still format.