snaptools
S
SQL Formatter error
⌃⏎ run · clear · / focus input
// about this tool

SQL Formatter Online

Updated 2026-07-09

Beautify SQL queries right in your browser. Paste a cramped, one-line query into the editor and SnapTools returns clean, indented output as you type — with capitalized keywords, aligned clauses, a dialect option, and one-click copy or download. Nothing is uploaded: all formatting happens locally, so it's safe for queries that reference private schemas.

A well-formatted query is far easier to read, review, and debug than a single dense line. Whether you're untangling a multi-table join, standardizing style across a team, or cleaning up SQL pulled from a log, the SQL Formatter gives you readable structure in one step.

// how to use

  1. 1 Paste or type your SQL into the input panel on the left — formatting starts as you type.
  2. 2 Open Settings to pick the SQL dialect and choose indentation (2, 4, or 8 spaces).
  3. 3 Read the formatted query on the right with capitalized keywords and aligned clauses.
  4. 4 Click Copy or Download to take the result with you.

// examples

One-line query to readable
Input
select id, name from users where active = 1 order by name
Output
SELECT
  id,
  name
FROM users
WHERE active = 1
ORDER BY name
Join across tables
Input
select o.id, u.name from orders o join users u on u.id = o.user_id where o.total > 100
Output
SELECT
  o.id,
  u.name
FROM orders o
JOIN users u ON u.id = o.user_id
WHERE o.total > 100

// common uses

Making one-line queries readable Standardizing query style before a code review Debugging complex joins and subqueries Tidying SQL copied from logs or an ORM

// faq

No. Formatting runs entirely in your browser, so your queries never leave your machine — safe for queries that reference private schemas or data.
Open Settings to choose your dialect (such as standard SQL, MySQL, or PostgreSQL) so dialect-specific keywords and syntax are handled correctly.
No. The formatter only reflows whitespace and capitalizes keywords for readability; the logic and results of the query stay exactly the same.
This tool understands SQL clauses, keywords, and joins and lays them out accordingly, while the JSON and HTML formatters handle their own structures. Use the right formatter for each language.
No. Only SQL keywords like SELECT, FROM, and WHERE are capitalized; your identifiers are left untouched so case-sensitive names stay correct.

↳ Curious to go deeper? Read the How to format SQL for readability guide →

Use this via API

Get a free API key →
curl -X POST https://snaptools.dev/api/v1/tools/sql-formatter \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"sql":"select id, name from users where active = 1 order by name"}'
Esc
↑↓ navigate open Esc close