WRRK Tools
All toolsBlogWRRK CRM
QR Code Tools
PDF Tools
Image Tools
Developer Tools
India Tools
© 2026 WRRK Tools. Free forever.Built by WRRK — the AI workspace for modern teams.
Tools/SQL Formatter

SQL Formatter

Paste a one-liner SQL query, get readable formatted output. Uppercase keywords, line breaks before JOIN, WHERE, GROUP BY. Browser-only.

Quick answer

A SQL formatter takes a flat, hard-to-read SQL string (often pasted from a log, ORM, or one-line dump) and reshapes it with uppercase keywords and line breaks before major clauses like JOIN, WHERE, GROUP BY, and ORDER BY. WRRK's formatter runs in your browser, works for Postgres, MySQL, and SQLite, and never sends your query to a server.

SQL input
1 lines · 235 chars
Formatted SQL
SELECT u.id, u.name, COUNT(o.id) AS order_count
FROM users u
LEFT
  JOIN orders o
  ON o.user_id = u.id
WHERE u.active = TRUE
  AND u.created_at > '2024-01-01'
GROUP BY u.id, u.name
HAVING COUNT(o.id) > 5
ORDER BY order_count DESC
LIMIT 100;
✓ Formatted

About this tool

SQL shows up in production logs, ORM debug output, and BI tools as flattened one-liners that nobody can read. WRRK's SQL formatter turns those one-liners into the canonical multi-line shape every engineer expects: keywords uppercased, each major clause (FROM, WHERE, JOIN, GROUP BY, ORDER BY, HAVING, LIMIT) on its own line, and long SELECT column lists broken onto separate indented rows.

The formatter works for the cross-dialect subset of SQL shared by Postgres, MySQL, MariaDB, SQLite, and SQL Server. It correctly detects single-quoted strings and double-quoted identifiers so your string literals (and any keywords inside them) are left untouched. JOIN variants (INNER, LEFT, RIGHT, FULL, CROSS) each start on their own line with ON conditions indented underneath. Everything runs locally in your browser — no upload, no logging — which matters when the query references customer tables, internal schemas, or anything you can't paste into a third-party site.

How to format SQL (5 steps)

  1. Paste your SQL. Drop a query into the left input panel. Click 'Sample' to load an example.
  2. Watch the output. Formatted SQL appears live — keywords uppercased, major clauses on new lines.
  3. Verify joins look right. INNER/LEFT/RIGHT JOIN clauses each start on their own indented line, with ON clauses indented under them.
  4. Copy or download. Click 'Copy' to put it in your clipboard, or 'Download' to save as .sql.
  5. Paste back into your editor. Drop the formatted SQL into your IDE, migration file, or BI tool.

Use cases

  • Reading flattened SQL from production logs and slow-query reports
  • Beautifying ORM-generated SQL (Sequelize, Prisma, ActiveRecord)
  • Cleaning up queries before pasting into a migration file
  • Reformatting SQL pulled from BI tools like Metabase or Looker
  • Code reviews — making PR diffs easier to read
  • Documentation — embedding clean SQL in runbooks and READMEs
  • Teaching — showing canonical SQL formatting to junior engineers

Frequently asked questions

+−How do I format SQL online?

Paste your SQL on the left — formatted output appears instantly on the right. Keywords get uppercased and major clauses (FROM, WHERE, JOIN, GROUP BY, ORDER BY) start on new lines.

+−What dialects does this support?

It works for the common subset shared by Postgres, MySQL, MariaDB, SQLite, and SQL Server: SELECT, JOIN, WHERE, GROUP BY, HAVING, ORDER BY, INSERT, UPDATE, DELETE, plus DDL like CREATE TABLE. Vendor-specific extensions still pass through unchanged.

+−Will it break my string literals?

No — single-quoted strings and double-quoted identifiers are detected and left untouched. Keywords inside strings (like a comment 'SELECT * FROM') won't be uppercased or have line breaks injected.

+−Why are my SELECT columns on one line?

Short SELECT lists stay inline. If the SELECT line goes over 60 characters, columns are split onto separate lines, one per row, indented two spaces — the canonical readable layout.

+−Is my SQL uploaded anywhere?

No. The formatter runs in your browser — no network calls. Safe for production queries with sensitive table names, customer data references, or internal schema.

+−Can I undo the formatting?

Click 'Sample' to load a fresh example, or use your editor's undo (Ctrl+Z / Cmd+Z) inside the input panel. The formatter is purely additive — no destructive transforms beyond whitespace and keyword case.

+−Does it format CTEs (WITH clauses) and subqueries?

Yes — WITH is recognized as a keyword and uppercased. Top-level subqueries and CTEs are kept on their own lines. Deeply nested subqueries inside parentheses are kept inline by design (we don't try to re-indent inside parens).

More free tools

QR Code Generator

URL, WhatsApp, WiFi, UPI, vCard — with logo

WhatsApp Link Generator

wa.me click-to-chat + group invite QR

Image Compressor

Compress to exact KB — for govt forms

Image Resizer

Resize JPG, PNG & WebP by pixels or percentage