Skip to content
NewKitApp

Search tools

Jump to any tool by name

SQL Formatter

Pretty-print messy or minified SQL with proper clause indentation.

What is SQL Formatter?

SQL Formatter takes a cramped or minified SQL query and reformats it with proper line breaks and indentation, entirely in your browser. It recognizes the major clause keywords — SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY, and more — and starts each one on its own line, with AND/OR conditions indented under the WHERE clause they belong to. It leaves string literals completely untouched, so a keyword that happens to appear inside quoted text (like the word "from" in an error message column) is never mistaken for actual SQL syntax. This isn't a full SQL parser or a query validator — it doesn't check that your SQL is semantically correct — it's a fast, readable-formatting pass for query you're staring at, debugging, or about to paste into a code review.

How to Use SQL Formatter

  1. Paste your SQL query into the input box.
  2. Toggle "Uppercase keywords" on or off depending on your house style.
  3. The formatted result appears instantly below, with each clause on its own line.
  4. Copy the formatted query with the copy button.

Examples

A one-line query

Input: select id, name from users where active = 1 and role = 'admin'

Output: SELECT id, name FROM users WHERE active = 1 AND role = 'admin'

A join

Input: select * from orders inner join customers on orders.customer_id = customers.id

Output: SELECT * FROM orders INNER JOIN customers ON orders.customer_id = customers.id

Common Mistakes

  • Expecting per-column line breaks inside a long SELECT list — this tool only breaks at clause boundaries, not inside expressions.
  • Pasting a query with an unterminated string literal (a stray unmatched quote) — the tool flags this as an error rather than guessing where the string was meant to end.
  • Assuming formatting means validation — a syntactically reformatted query can still be logically wrong or reference tables that don't exist.
  • Mixing single and double quotes and expecting both to be treated as string delimiters — only single-quoted literals are protected, matching standard SQL string syntax.

Why Use This Tool

  • Processes entirely client-side — your query never leaves your browser.
  • String literals are protected from accidental keyword-breaking, even when they contain SQL keyword words.
  • Toggle to keep your own keyword casing instead of forcing uppercase.
  • Instant, live formatting with no submit button.

Frequently Asked Questions