Back to guides

SQL Formatter|Format one-line SQL from slow-query logs before the code review

Paste a single-line SELECT from MySQL slow logs or ORM debug output, break JOINs and WHERE clauses in the browser SQL formatter, compress again for tickets. No execution, no database connection.

By WGinit · November 20, 2026 · 5 min read

Why format first

Incidents and reviews often arrive as one line: SELECT u.id,u.name,o.total FROM users u LEFT JOIN orders o ON u.id=o.user_id WHERE o.total>100 AND u.status='active' ORDER BY o.total DESC LIMIT 50. JOIN keys and filters hide in the middle.

Open SQL Formatter, paste the statement, choose Format, run once. The tool collapses whitespace, inserts line breaks before major keywords (SELECT, FROM, WHERE, JOIN, ORDER BY, …), and indents lines that start with AND, OR, or ON.

Processing stays in the browser tab; Nothing executes against your database and the payload is not sent to WoDeTool for execution. Use staging samples; redact customer fields before you paste.

Before you close the tab, save one sentence in your runbook about which step surfaced the root cause and whether a script could replace the browser chain next quarter. Short retrospectives beat perfect prose for on-call handoffs.

Format versus compress

Format produces a multi-line, human-readable statement for PR descriptions, tickets, and pairing sessions.

Compress folds the statement back to a single line—handy for test fixtures or checking whether a log line differs only by whitespace.

Neither mode changes keyword casing, quoting, or dialect-specific tokens such as PostgreSQL ::jsonb. Line breaks follow a shared keyword list, not a full grammar per engine.

Before you close the tab, save one sentence in your runbook about which step surfaced the root cause and whether a script could replace the browser chain next quarter. Short retrospectives beat perfect prose for on-call handoffs.

What the formatter does and does not do

This is keyword-driven layout, not a validating parser. String literals that contain words like AND can occasionally receive an extra break—fall back to your SQL client when that happens.

Common WITH clauses (CTEs) are outside the break list and may remain on one line. Insert a manual line break before WITH, then format the body.

Syntax is not checked against MySQL, PostgreSQL, or SQLite. Run EXPLAIN or a staging query before you merge. Like JSON Formatter, the browser helps you read; execution stays in your pipeline.

Before you close the tab, save one sentence in your runbook about which step surfaced the root cause and whether a script could replace the browser chain next quarter. Short retrospectives beat perfect prose for on-call handoffs.

End-to-end workflow (diagram)

Hands-on order: paste → format → read JOIN/WHERE → use Text Diff when you change indexes or aliases; Text Replacer can rename tables on the formatted text under control.

Diff after formatting surfaces which ON clause or AND branch moved—easier than diffing two minified lines.

Before you close the tab, save one sentence in your runbook about which step surfaced the root cause and whether a script could replace the browser chain next quarter. Short retrospectives beat perfect prose for on-call handoffs.

Dialect, privacy, and triage

Redact emails, phone numbers, and company names inside literals before sharing. Reviewers still read WHERE values in plain text.

ORM output with DATE_FORMAT, TO_CHAR, or similar keeps function semantics—only spacing changes. Attach EXPLAIN output beside the formatted SQL when you document index work.

Before you close the tab, save one sentence in your runbook about which step surfaced the root cause and whether a script could replace the browser chain next quarter. Short retrospectives beat perfect prose for on-call handoffs.

FAQ

After format, GROUP BY sits above ORDER BY oddly—did semantics change: No. Breaks insert before keywords only; illegal SQL stays illegal. Confirm with EXPLAIN on the target engine.

How do I diff SQL before and after a DBA index tweak: Format both versions, then run Text Diff. Minified one-liners hide ON edits.

Backtick table names from MySQL logs: Preserved; only whitespace and keyword breaks change.

Does compress strip comments: Comments travel with the text; compress merges whitespace only. Line comments may sit beside keywords after format—tweak manually if style guide requires.

Before you close the tab, save one sentence in your runbook about which step surfaced the root cause and whether a script could replace the browser chain next quarter. Short retrospectives beat perfect prose for on-call handoffs.

Worked example (step by step)

1. Slow log line: SELECT p.id,p.sku,i.qty FROM product p INNER JOIN inventory i ON p.id=i.product_id WHERE i.qty<5 AND p.deleted=0 ORDER BY i.qty ASC LIMIT 20.

2. Copy from SELECT through LIMIT 20 into SQL Formatter; choose Format.

3. Verify INNER JOIN is on its own line and ON p.id=i.product_id is easy to spot next to AND branches.

4. Before a suggested index, format the current statement and a draft with FORCE INDEX.

5. Paste both multiline versions into Text Diff; read only the FROM/JOIN hunk.

6. Put the multiline copy in the ticket; compress back to one line for a test fixture.

7. To rehearse renaming orders → orders_archive, use Text Replacer on the formatted text with a narrow scope.

8. If the ticket has a size cap, check length with Word Counter and trim prose, not truncated SQL.

Before you close the tab, save one sentence in your runbook about which step surfaced the root cause and whether a script could replace the browser chain next quarter. Short retrospectives beat perfect prose for on-call handoffs.

Related tools

Related guides