SQL Formatter

Works fully offline

Paste a minified or messily-formatted SQL query and get back a clean, indented version with each clause on its own line.

0 characters

    

Overview

A single-line or inconsistently indented SQL query gets hard to read once it has more than a couple of JOINs or WHERE conditions. This tool re-indents a query so each major clause (SELECT, FROM, WHERE, JOIN, ORDER BY, and so on) starts on its own line, with nested expressions indented underneath it, and reports a specific parse error — with a line and column when available — instead of guessing at a fix for invalid SQL.

Examples

Formatting a query with a WHERE clause

select id, name from users where active = true and age > 18 order by name
SELECT
  id,
  name
FROM
  users
WHERE
  active = TRUE
  AND age > 18
ORDER BY
  name

How It Works

  1. Paste your SQL query into the input box.
  2. Optionally toggle uppercase keywords and choose 2-space or 4-space indentation.
  3. Click Format SQL to see the formatted result.

Use Cases

Cleaning up a query pasted from a log or a colleague

Turn a single-line query copied from an application log or a Slack message into something readable before debugging it.

Standardizing style before a PR review

Run a hand-written migration or report query through the formatter so its style matches the rest of the codebase before committing.

Tips

  • This formats generic ANSI-ish SQL — dialect-specific syntax from a particular database may format less predictably around its own extensions.

FAQ

No. Formatting happens entirely in your browser using a bundled formatting library — your SQL never leaves your device.

The tool shows a specific parse error describing where it stopped understanding the query, instead of guessing at a fix or showing partial output.

No — this only reformats the query's syntax for readability. It doesn't connect to any database, and doesn't check that tables or columns actually exist.

Yes — toggle uppercase keywords on or off, and choose 2-space or 4-space indentation, before formatting.

Related Tools