SOQL Formatter & Beautifier
Paste any SOQL query — from a one-line SELECT to a nested relationship query with TYPEOF branches and WITH SECURITY_ENFORCED — and get cleanly indented, keyword-capitalized SOQL as you type. Formatting runs in a background Web Worker, so even massive queries never freeze the page, and nothing you paste ever leaves your browser.
Salesforce-native parser
Subqueries, __c / __r / __mdt field paths, TYPEOF, and date literals parsed atomically.
Formats as you type
A persistent Web Worker re-indents every keystroke without blocking the UI thread.
Zero-upload architecture
No backend exists — queries describing your org schema never leave this tab.
Paste a SOQL query to format
SOQL query
Formatted SOQL
Type or paste a SOQL query — clean, indented SOQL appears here instantly, formatted in a background worker.
How the SOQL formatter works
A parser built for SOQL, not recycled SQL
Generic SQL formatters assume ANSI dialects and stumble the moment they meet Salesforce syntax. This tool ships a purpose-built, token-based parser: it lexes your query into keywords, field paths, string literals, date literals, bind variables, and parenthesis structure before applying any layout rules. That distinction matters for correctness — SOQL keywords are case-insensitive but field API names are not, so the formatter uppercases clause keywords (SELECT, FROM, WHERE, GROUP BY, ORDER BY, LIMIT) while leaving field names, aliases, and object names exactly as you typed them. No sql-formatter dependency, no server round trip: the entire grammar, from TYPEOF polymorphic expressions down to USING SCOPE, ships with the page as plain TypeScript.
Subqueries indent the way Apex developers read them
Relationship queries are where SOQL formatting gets hard. Parent-to-child subqueries — (SELECT LastName, Email FROM Contacts) nested inside a SELECT list — and semi-join subqueries inside WHERE Id IN (SELECT AccountId FROM Contact) are detected by tracking parenthesis depth, so each nested query's SELECT, FROM, WHERE, and ORDER BY clauses line up one indentation level deeper than the query that contains them. Comma-separated SELECT lists break onto one field per line once they grow past three fields or past the line-length budget, long WHERE conditions align their AND/OR connectors at a consistent indent, and subqueries nested inside subqueries keep stacking cleanly instead of collapsing into a single unreadable line.
Custom fields, relationships, and metadata objects stay atomic
Salesforce field names carry meaning in their suffixes: AnnualRevenue is standard, Deal_Size__c is a custom field, Account__r.Region__c traverses a relationship, Revenue_Country__mdt is a custom metadata type, and ns__Field__c carries a managed-package namespace. The tokenizer treats every dotted path as one atomic token, so Contact__r.Custom_Field__c is never split at the dot, never re-cased, and never confused with a clause keyword. The same care extends to SOQL literals: datetime values like 2024-01-15T10:30:00Z, date functions like LAST_N_DAYS:90, currency literals like USD5000, and Apex bind variables like :maxRows all survive formatting byte-for-byte.
WITH SECURITY_ENFORCED and modern clauses are first-class
Contemporary SOQL is more than SELECT/FROM/WHERE. The formatter recognizes WITH SECURITY_ENFORCED — plus WITH USER_MODE and WITH SYSTEM_MODE — as dedicated clause lines, understands WITH DATA CATEGORY filters without breaking their internal AND/OR logic, and lays out the full tail of a query: GROUP BY with HAVING, ORDER BY Name DESC NULLS LAST, LIMIT and OFFSET, FOR VIEW, FOR UPDATE, ALL ROWS, and USING SCOPE. Aggregate functions such as COUNT, COUNT_DISTINCT, SUM, toLabel, and convertCurrency get canonical casing while their aliases stay exactly yours.
Your queries describe your org — so they never leave your browser
A pasted SOQL string is a map of your enterprise: object names, custom field names, picklist values, and filter constants together describe your schema and your business. That is why this formatter has no backend that could receive it. The page is statically exported, formatting executes in a Web Worker inside your own tab, and a quick look at the browser network tab confirms that zero requests ever carry your query text. It works on a plane, behind a VPN, or in an air-gapped environment — and because the formatter is total rather than validating, even malformed or half-typed queries are harmlessly re-indented instead of throwing an error.
Frequently asked questions
Is my SOQL query uploaded to a server?
No. The formatter is compiled into the page itself and executes in a Web Worker inside your browser tab. Open your network panel while typing — no request ever carries your query text. Nothing is transmitted, logged, or stored.
Does the formatter execute my query or connect to Salesforce?
No. Formatting is purely lexical: it rewrites whitespace, line breaks, and keyword casing only. The tool never calls the Salesforce REST or SOAP APIs, never asks for a login, cannot hit org limits, and will happily format queries for objects that do not exist.
How are subqueries and relationship queries formatted?
Parent-to-child subqueries in the SELECT list and semi-join subqueries inside WHERE Id IN (SELECT …) are detected through parenthesis tracking, then indented one additional level so each nested SELECT, FROM, and WHERE lines up beneath the query that contains it. Nesting stacks cleanly at any depth.
Will it change my custom field names or Apex bind variables?
No. Clause keywords such as SELECT and WITH SECURITY_ENFORCED are uppercased, but field paths (Deal_Size__c, Account__r.Region__c, Revenue_Country__mdt), aggregate aliases, and Apex bind variables like :maxRows keep their exact casing and are never split at dots.
Which SOQL features does the formatter understand?
TYPEOF polymorphic expressions, WITH SECURITY_ENFORCED / USER_MODE / SYSTEM_MODE, WITH DATA CATEGORY, GROUP BY with HAVING, ORDER BY … NULLS FIRST/LAST, LIMIT and OFFSET, FOR VIEW / FOR UPDATE, ALL ROWS, USING SCOPE, date literals like LAST_N_DAYS:90, currency literals like USD5000, and Apex bind variables.
Can I use the SOQL formatter offline?
Yes. This page is a static export with no runtime backend. Once it has loaded, you can disconnect the network and formatting keeps working — including copy and download of the formatted output.