apexfmt
apexfmt
Format Apex code automatically.
Usage
# Format file to stdout
apexfmt MyClass.cls
# Format and overwrite files
apexfmt -w *.cls *.trigger
# Check which files need formatting
apexfmt -l sfdx/main/default/classes/*.cls
# Format SOQL query
echo "SELECT Id, Name FROM Account WHERE Type = 'Customer'" | apexfmt -s
# Format from stdin
cat MyClass.cls | apexfmtWhat it does
- Uses tabs for indentation (like gofmt)
- Formats method chaining and parameters
- Properly indents conditionals and loops
- Formats SOQL queries with line breaks
- Preserves comments
- Handles collections and object initialization
Options
-w, --write- Overwrite files in-place-l, --list- List files that need formatting-s, --soql- Format SOQL from stdin-v, --verbose- Debug logging
Installation
Download binary for your platform:
Or try online: apexfmt.octoberswimmer.com
Price
Free - Open source