A C# formatter that reads your .editorconfig, all of it, and reflows code to a line width the way Prettier does.
Curb honours the complete set of .NET formatting options (code style rule
IDE0055). Its defaults are
Roslyn's defaults, so it agrees with Visual Studio and Rider out of the box; max_line_length opts into reflow on top.
dotnet add package curbor, by hand:
<PackageReference Include="curb" Version="*" PrivateAssets="all" />Curb runs before CoreCompile, rewriting source in Debug and checking in Release. With EnforceCodeStyleInBuild
set, the only style diagnostics left are the ones that genuinely require a compilation: everything mechanical is
already fixed before the compiler reads the file.
This is the recommended integration for most projects. It is particularly effective in agentic workflows: any code an agent writes or edits is formatted automatically on the next build, without the agent having to think about it. See the build integration docs.
dotnet tool install -g curb-cliShips as a native-AOT binary per platform (linux-x64, linux-arm64, win-x64, win-arm64, osx-arm64), with a
portable fallback. About 10 ms startup.
curb format ./src # format in place
curb check ./src # exit 1 if anything would change
curb print-config Foo.cs # show every resolved option and its sourceFor code style rules that need a compilation (unused usings, var, naming), run a build first and let Curb read what
it reported:
dotnet build && curb cleanupcurb rules lists what Curb fixes and what it leaves to dotnet format style.
Fast enough to run on every build. Curb is a native-AOT binary with no warm-up cost. Measured cold on Newtonsoft.Json (945 files):
| curb | dnf whitespace | CSharpier | |
|---|---|---|---|
| Newtonsoft.Json (945 files) | 0.26 s | 3.47 s | 4.85 s |
dnf whitespace is dotnet format whitespace, the whitespace-only pass and Curb's closest equivalent. Across twelve
real repositories Curb is 5–25× faster than dotnet format whitespace, while doing more: it reflows long lines, sorts
using directives, and applies syntax-level code style on top. Fast enough to wire into dotnet build and forget about
it. Full numbers: Benchmarks.
On subsequent builds the MSBuild integration skips unchanged projects entirely: no process starts. For projects with changes, only the files that changed since the last build are reformatted. Curb is fast cold, faster warm.
Plays well with your IDE and dotnet format. Curb supports the full set of .editorconfig formatting properties
that Visual Studio, Rider and dotnet format read: all 39 csharp_* and dotnet_* keys of
IDE0055, plus the ReSharper
wrapping and blank-line keys. Running dotnet format whitespace over Curb's output never disagrees: measured across
41,000 files, gated on every push.
Declare Fantomas in your tool manifest (dotnet tool install fantomas) and curb format and curb check cover your
.fs, .fsi and .fsx files too, through that exact version, with Curb's cache, MSBuild target and safety check on
top: a result is written only if Fantomas leaves it unchanged when it is sent back. Without the manifest entry nothing
changes. See F# through Fantomas.
Opt in from a section that names Razor files, and curb format and curb check format the C# in the @code,
@functions and @{ } blocks of .razor and .cshtml files with your C# options. A second key re-indents the
markup by its nesting, as Microsoft's Razor formatter does, and places continued attributes by
razor_attribute_indent_style:
[*.{razor,cshtml}]
curb_razor_format_code_blocks = true
curb_razor_format_markup = trueMarkup changes only in its indentation. Directives and expressions stay exactly as written, and the MSBuild package never formats Razor files. See Razor.
| Package | What it is | |
|---|---|---|
curb |
MSBuild integration: formats before CoreCompile on every build |
|
curb-cli |
the curb .NET tool: format, check, print-config, cleanup, rules |
- Documentation: https://curb.nullean.net, with the full option reference, design rationale and the build integration guide
- Known limitations
- Building from source:
git clone git@github.com:nullean/curb.git, thenmise run buildandmise run test(mise installs the .NET SDKglobal.jsonnames) - Releases
- Contributing
MIT licensed. Copyright Nullean and contributors.
