RazorFmt.Cli
0.3.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet tool install --global RazorFmt.Cli --version 0.3.0
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
dotnet tool install --local RazorFmt.Cli --version 0.3.0
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=RazorFmt.Cli&version=0.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
nuke :add-package RazorFmt.Cli --version 0.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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
razorfmt --wrap-attributes . # wrap long tags, one attribute per line
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
@codeblocks (@<div> ... </div>) is preserved as written, not reformatted. --split-tagshandles markup lines and inline Razor blocks; it does not split C# statements inside@codeblocks.- Splitting tags can add whitespace between inline elements; the option is off by default.
--wrap-attributesonly wraps a tag when it is the whole line. Tags followed by text or child markup are left alone.- 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 | 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.