Shard Tools

SQL Formatter

Format SQL instantly in your browser.

Maintained by Roshan.

Use SQL Formatter

Converts sql to formatted sql in this tab, with nothing sent anywhere.

Runs entirely on your deviceThe conversion happens in this browser tab. Nothing you type is uploaded, logged or stored, which is worth knowing for anything you would not paste into a search box.

Explore developer and data tools

Find related browser-local tools for nearby tasks without starting another search.

Browse all developer and data tools

About SQL Formatter

A SQL formatter takes a query crammed onto one line and lays it out so a person can read it - each major clause on its own line, columns broken out, keywords capitalised. Long queries arrive as unbroken strings from logs, code and ORMs, and they are almost impossible to review or debug in that state; a missing join condition or a misplaced filter hides easily. This tool reformats your SQL in the browser into a clean, indented shape that makes its structure obvious. It runs entirely on your device, so a query that embeds table names, column names and business logic you would rather keep private never leaves the tab.

Using SQL Formatter

  1. Paste your SQL, however densely it is written. It is reformatted in this browser tab.
  2. Major keywords - SELECT, FROM, WHERE, JOIN, GROUP BY and the rest - are moved to their own lines and capitalised, and column lists are broken out.
  3. Copy the formatted query. Its structure is now visible at a glance, which is what makes review and debugging quick.

Where sql formatter helps

Reading a logged query

A one-line query pulled from a slow-query log becomes a readable block where a missing join condition is obvious.

Reviewing an ORM query

The dense SQL an ORM emits is formatted so a reviewer can actually check what it does.

Review statements before executing them

Formatting is for inspection and does not validate permissions, transaction boundaries or the effect of a query. Check identifiers, predicates and quoted values against the original, particularly with dialect-specific syntax. Test a changed query in an appropriate development database before running it on production data.

Before you use the result

Questions about SQL Formatter

Does formatting change my query?

No. It changes only spacing and keyword case, so the formatted query returns exactly the same results as the original.

Will it handle every SQL dialect?

It handles common SQL well. Very unusual vendor extensions may not lay out perfectly, but the query is never altered in meaning.

Related tools

SQL Minifier

SQL Minifier in your browser. Instant, accurate, and nothing is uploaded.

JSON to SQL

Turn a JSON array into SQL INSERT statements in your browser, with quotes escaped correctly.

CSS Formatter

CSS Formatter in your browser. Instant, accurate, and nothing is uploaded.