Apex & SOQL Formatter — Free Salesforce Developer Tool
Skip to main content

Apex & SOQL Formatter

Instantly format raw SOQL queries and beautify messy Apex snippets locally in your browser.

About the Apex & SOQL Formatter

Unformatted Apex code is hard to review and harder to debug. Whether you're cleaning up auto-generated code, normalizing a team's inconsistent style, or preparing code for a pull request, this formatter re-indents and normalizes whitespace in Apex classes, triggers, and SOQL queries — instantly, in your browser.

What this tool formats

Apex Classes & Triggers

Re-indents class bodies, method signatures, control flow blocks, and annotations. Normalizes brace placement and spacing around operators.

SOQL Queries

Aligns SELECT fields, FROM clause, WHERE conditions, ORDER BY, GROUP BY, LIMIT, and OFFSET on separate lines for maximum readability.

Apex code quality tips

  • Keep methods under 20 lines — long methods are harder to test and review
  • One SOQL query per method where possible — avoid queries inside loops
  • Use with sharing on all classes unless you have a specific reason not to
  • Bulkify all trigger logic — always handle Trigger.new as a list

Pipeline

Frequently asked

Is my Apex code sent to a server?
No. All formatting runs 100% in your browser. Your Apex code — including any business logic or credentials — never leaves your device.
What is the difference between Apex and SOQL formatting?
Apex formatting re-indents and normalizes whitespace in Apex class and trigger code. SOQL formatting specifically targets SELECT queries — aligning keywords, clauses, and conditions for readability.
Why should I format my Apex code?
Consistent formatting makes code reviews faster, reduces merge conflicts caused by whitespace differences, and makes it easier to spot logic errors. Salesforce's own Apex PMD rules flag inconsistent formatting as a code quality issue.
Does the formatter change my logic?
No. The formatter only adjusts whitespace, indentation, and line breaks. It does not rename variables, reorder statements, or modify any executable logic.
Can I use this to format SOQL inside Apex strings?
Switch to SOQL mode and paste the query directly. The formatter handles SELECT, FROM, WHERE, GROUP BY, ORDER BY, LIMIT, and OFFSET clauses with proper indentation.