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 sharingon all classes unless you have a specific reason not to - Bulkify all trigger logic — always handle
Trigger.newas a list
Pipeline
- SOQL Builder — build your query visually, then format it here.
- Apex Trigger Builder — generate a trigger scaffold, then format it.
- Debug Log Analyzer — analyze the runtime behavior of your formatted code.
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.
Related Tools
JSON to Apex Generator
Generate Apex wrapper classes from JSON structures.
Log Analyzer
Parse and filter Salesforce debug logs by event type.
SQL Formatter
Beautify SQL and SOQL queries with dialect-aware formatting.
15 to 18 Char ID
Convert Salesforce 15-character IDs to 18-character case-safe IDs.
Governor Limits Reference
Searchable reference of all Salesforce governor limits with sync/async values and best practices.
JSON Formatter / Validator
Format, validate, and beautify JSON with syntax highlighting.