RazorFmt.Cli 0.2.1

There is a newer version of this package available.
See the version list below for details.
dotnet tool install --global RazorFmt.Cli --version 0.2.1
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local RazorFmt.Cli --version 0.2.1
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=RazorFmt.Cli&version=0.2.1
                    
nuke :add-package RazorFmt.Cli --version 0.2.1
                    

RazorFmt

RazorFmt is an experimental command-line formatter for .razor and .cshtml files. It indents markup and formats the C# in @code / @functions, pure-C# @{ ... } blocks, control-flow headers, and @( ... ) expressions with Roslyn.

Install

dotnet tool install --global RazorFmt.Cli

Usage

razorfmt Page.razor          # print the formatted file to stdout
razorfmt --check .           # list files that would change
razorfmt --write .           # rewrite files in place
razorfmt --split-tags .      # also put adjacent tags on separate lines

Directories are scanned recursively for .razor and .cshtml files. A file is only rewritten when formatting succeeds; malformed or unsupported input is reported and left unchanged. Files keep their original encoding and line endings, with .editorconfig end_of_line taking precedence.

Known limitations

  • Razor template syntax inside @code blocks (@<div> ... </div>) is preserved as written, not reformatted.
  • --split-tags handles markup lines and inline Razor blocks; it does not split C# statements inside @code blocks.
  • Splitting tags can add whitespace between inline elements; the option is off by default.
  • Attribute continuation lines are normalized to one indent level instead of preserving manual alignment.

Safety

C# is formatted by Roslyn; RazorFmt only locates the spans. Unsupported structure fails closed instead of being guessed at. Run --check first and review changes before --write.

License

MIT

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
0.7.0 104 11/13/2026
0.6.0 103 11/4/2026
0.3.0 96 11/3/2026
0.2.1 82 11/3/2026
0.2.0 93 11/3/2026
0.1.1 97 11/3/2026
0.1.0 106 11/2/2026