FastFormat 1.2.2
See the version list below for details.
dotnet tool install --global FastFormat --version 1.2.2
dotnet new tool-manifest
dotnet tool install --local FastFormat --version 1.2.2
#tool dotnet:?package=FastFormat&version=1.2.2
nuke :add-package FastFormat --version 1.2.2
FastFormat
A fast C# formatter that supports common formatting-related .editorconfig options. Designed for rapid development with format-on-save workflows.
FastFormat is not a replacement for dotnet format. It is a fast intermediary between no formatting and waiting several seconds for a full dotnet format run. Use it when you want formatting feedback quickly, then rely on dotnet format (or CI) for comprehensive validation.
Performance
benchmark.sh creates a synthetic C# project, builds FastFormat in Release mode, then runs best-of-5 timings against the compiled FastFormat binary and dotnet format.
Recent local results on Linux with .NET 10:
| Corpus | Mode | FastFormat | dotnet format |
Ratio |
|---|---|---|---|---|
| 10 files × 50 props | Cold rewrite | 626ms | 4076ms | 6.5× |
| 10 files × 50 props | No-op | 586ms | 3918ms | 6.7× |
| 10 files × 50 props | Check | 625ms | 4021ms | 6.4× |
| 100 files × 200 props | Cold rewrite | 1299ms | 6652ms | 5.1× |
| 100 files × 200 props | No-op | 1008ms | 6455ms | 6.4× |
| 100 files × 200 props | Check | 1312ms | 6639ms | 5.1× |
| 200 files × 500 props | Cold rewrite | 3189ms | 14295ms | 4.5× |
| 200 files × 500 props | No-op | 2139ms | 13409ms | 6.3× |
| 200 files × 500 props | Check | 3076ms | 14810ms | 4.8× |
Caveats: this is a synthetic corpus, not a substitute for benchmarking your real solution. dotnet format does MSBuild workspace loading and broader analysis; FastFormat intentionally skips that work to be a fast format-on-save/intermediate formatter.
Run it yourself:
./benchmark.sh 100 200
./benchmark.sh --verbose 200 500
Installation
dotnet tool install --global FastFormat
Usage
# Format files or directories
# (refuses to run on non-project directories without --force)
dotnet-fastformat src/
dotnet-fastformat Program.cs
# Check formatting without making changes
dotnet-fastformat --check src/
# Include/exclude patterns
dotnet-fastformat --exclude "**/*.generated.cs" src/
dotnet-fastformat --include "src/**/*.cs" --include "tests/**/*.cs" .
# Bypass the project-directory safety check
dotnet-fastformat --force ~/some-random-dir/
# Stdin -> stdout
cat Program.cs | dotnet-fastformat
cat Program.cs | dotnet-fastformat --stdin-filepath src/Program.cs
# Verbose output
dotnet-fastformat -v src/
# Control parallelism
dotnet-fastformat -p 8 src/
Supported .editorconfig Options
indent_styleindent_sizetab_widthend_of_lineinsert_final_newlinetrim_trailing_whitespacecsharp_new_line_before_open_bracecsharp_new_line_before_catchcsharp_new_line_before_elsecsharp_new_line_before_finallycsharp_new_line_before_members_in_object_initializerscsharp_new_line_between_query_expression_clausesdotnet_sort_system_directives_firstdotnet_separate_import_directive_groups
File Types
.cs— C# source files.csx— C# script files
Safety
When run on a directory, FastFormat refuses to recurse unless the directory (or an ancestor) looks like a project — indicated by the presence of .git, .editorconfig, *.csproj, *.sln, or *.slnx. It also refuses to run directly on $HOME or the filesystem root. Use --force to bypass this check.
Encoding
Files are read and written preserving their existing BOM. Files without a BOM are assumed to be UTF-8.
Default Behaviors
- Final newline: Files are always given a trailing newline unless
.editorconfigexplicitly setsinsert_final_newline = false.
Why is it faster?
- No MSBuild workspace loading
- No semantic analysis
- Parallel file processing
- Direct
.editorconfigparsing without heavy workspace machinery - Gitignore-aware file discovery
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
This package has no dependencies.