SQL Formatter & Beautifier

Pretty-print SQL queries in your browser — keywords on their own lines.

Ad placeholder (leaderboard)
Enjoying the tools? Go Pro for £4.99 (one-time) and remove all ads — forever, on this device. Remove ads — £4.99

Paste a cramped one-line SQL query and get back a readable, reviewable layout. Each major clause goes on its own line, recognised keywords are upper-cased, and long conditions and select lists wrap onto indented continuation lines — ideal for pull requests, documentation, and debugging.

How it works

The formatter is a layout pass, not a parser:

  1. Tokenise. The query is broken into tokens on whitespace, parentheses, and quote boundaries. Quoted strings and identifiers ('...', "...", `...`) are detected here and passed through untouched.
  2. Line breaks. Major clauses — SELECT, FROM, WHERE, the JOIN family, GROUP BY, ORDER BY, LIMIT, and more — start a new line. AND/OR and commas in the SELECT list break onto indented continuation lines.
  3. Casing. Only recognised keywords are upper-cased; your identifiers keep their original case.

Because it re-lays-out rather than validates, it will not flag syntax errors — but it also never changes what your query does.

Example

Input:

select id, name, email from users where active = true and country = 'GB' order by name

Formatted (2-space indent):

SELECT
  id,
  name,
  email
FROM users
WHERE active = true
  AND country = 'GB'
ORDER BY name

Note the string literal 'GB' is preserved exactly. It is privacy-first plain JavaScript — your query never leaves your device.

Ad placeholder (rectangle)