SOQL Query Formatter
Pretty-print a SOQL query with each clause on its own line and subqueries indented, with optional uppercase keywords and a 2- or 4-space indent.
SOQL
Formatted
Output appears here.Pretty-print a SOQL query with each clause on its own line and subqueries indented, with optional uppercase keywords and a 2- or 4-space indent.
Output appears here.A one-line SOQL query is fine until it grows a handful of fields, a couple of subqueries, and a long WHERE clause, at which point it becomes hard to read in a code review or a log. This formatter takes a SOQL query and rewrites it with each major clause on its own line, subqueries indented one level deeper, and keywords optionally uppercased, so the structure of the query is obvious at a glance. String literals and bind variables are preserved exactly.
The formatter tokenises the query while keeping quoted string literals and bind expressions intact, then re-emits it clause by clause: SELECT, FROM, WHERE, WITH, GROUP BY, HAVING, ORDER BY, LIMIT, OFFSET, and FOR UPDATE each start a new line. Parenthesised subqueries in the SELECT list are formatted recursively and indented one level deeper than their parent. The uppercase-keywords toggle normalises clause and operator keywords without touching field or object names, and the indent control switches between two and four spaces. Formatting runs locally on each keystroke.