Format SQL Queries for Readability and Debugging

Published 2026-05-28

Format and prettify SQL queries in your browser. Supports SELECT, INSERT, UPDATE, CREATE. Private, no upload, no signup.

Try SQL Formatter free →

The problem

You get a SQL query from a Slack message, a log file, or a legacy codebase, and it's one long unbroken line. SELECT a.id, a.name, b.total FROM accounts a JOIN orders b ON a.id = b.account_id WHERE b.status = 'active' AND b.created > '2026-01-01' ORDER BY b.total DESC LIMIT 50. Good luck reading that in a code review.

Readable SQL has one clause per line, consistent indentation, and uppercase keywords. Formatting by hand is tedious. IDE plugins require installing extensions. Online formatters upload your queries to a server — fine for sample data, risky for production queries with real table names and business logic.

How it works

  1. Paste your SQL into the input panel — any dialect, any size.
  2. See it formatted instantly — major clauses on new lines, keywords uppercased, joins indented, subqueries nested.
  3. Adjust the style — choose 2-space, 4-space, or tab indentation. Toggle keyword casing. Select your dialect (Standard, MySQL, PostgreSQL) for dialect-specific keywords.
  4. Minify if needed — collapse the query back to a single line for embedding in code or config.
  5. Copy the result — one click to clipboard.

Your data never leaves your browser. All processing happens locally.

Why I built it

I read and write SQL daily — debugging queries, reviewing pull requests, digging through logs. Unformatted SQL is the norm in production systems, and reformatting it by hand gets old fast. I wanted something instant that I could keep in a tab — paste, read, done. No extensions to install, no server involved.

Tips and reference

Common SQL formatting conventions that make queries easier to read and review:

ConventionExampleWhy
Uppercase keywordsSELECT, FROM, WHEREVisually separates SQL syntax from your data
One clause per lineSELECT ...
FROM ...
WHERE ...
Each clause is scannable independently
Indent joins  JOIN orders ON ...Shows table relationships at a glance
Indent AND/OR  AND status = 'active'WHERE conditions are readable as a list
Trailing commas in SELECTa.id,
a.name,
a.email
Easy to add/remove columns, clean diffs

Note: This tool formats SQL — it doesn't validate it. If your query has a syntax error, the formatter will still indent it. The formatting just makes the error easier to spot.


Built with vanilla HTML/JS. No frameworks, no backend, loads instantly.

Related tools

Joe — Software engineer with 20+ years of experience. Built ToolRack to provide fast, private tools without the bloat.