Prettier plugin for formatting Razor (.cshtml) files used in ASP.NET Core MVC and Blazor. Current stable version is 1.0.11-alpha.1. Released irregularly as alpha. Key differentiator: brings consistent code formatting to Razor templates within the Prettier ecosystem, supporting directives like @code, @functions, and HTML/CSS/C# code segments. Alternatives include built-in Visual Studio formatters, but this plugin integrates with Prettier workflows and CI pipelines.
npm install prettier-plugin-razorVerified import paths — ran on the pinned version, not inferred.
Configure Prettier to use the Razor plugin for .cshtml files.
Pin to exact version in package.json.
Use Prettier CLI or API directly.
Check formatting output and raise issues on GitHub.
npm install --save-dev prettier-plugin-razor
Add 'parser: "razor"' to Prettier configuration.