About the SQL Formatter

A fast, private, browser-based tool for turning messy SQL into clean, readable queries.

What it is

The SQL Formatter is a free, client-side tool that reformats SQL queries into clean, consistently indented code. Paste a one-line or poorly formatted query and get back readable SQL with one clause per line, indented conditions, and aligned join and subquery structure — instantly, as you type.

Everything runs in your browser using JavaScript. No query, schema, or data is sent to a server — your SQL stays entirely on your device. The tool is built for developers, DBAs, and data analysts who work with SQL from ORMs, log files, migrations, or copy-pasted queries that never got formatted in the first place.

How formatting works

The formatter tokenizes the query — recognizing keywords, identifiers, strings, numbers, operators, and comments — then rebuilds it clause by clause. Major clauses (SELECT, FROM, WHERE, GROUP BY, ORDER BY, and similar) start on their own line; comma-separated lists like selected columns break one item per line; JOIN ... ON pairs are placed together; and AND/OR conditions in WHERE and HAVING clauses each get their own indented line. Parenthesized subqueries are indented one level deeper than the query that contains them, so nested structure stays easy to follow.

Features

Clause-based indentation

SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY and more each get their own line.

Subquery indentation

Nested SELECTs in parentheses indent one level deeper automatically.

Uppercase / lowercase keywords

Format keywords in UPPERCASE or lowercase without touching identifiers.

Adjustable indent

Choose 2 spaces, 4 spaces, or a tab character.

Minify mode

Collapse the query to a single compact line for configs or environment variables.

Syntax highlighting

Keywords, strings, numbers, and comments are colour-coded for fast scanning.

Handles INSERT, UPDATE, DELETE

Not just SELECT — full DML and CREATE TABLE statements are supported too.

Fully private

No server, no storage — every query stays in your browser.

Formatter, not validator

This tool reformats SQL structure and casing — it does not parse or validate against a specific database's grammar. It won't catch a missing table, a typo in a column name, or a syntax error that a real database engine would reject. For that, run the query against your actual database.

Ready to use it?

Free, no sign-up required.

Open the SQL Formatter