dotnet-format - Man Page

Formats code to match editorconfig settings.

dotnet format

This article applies to: ✔️ .NET 6 SDK and later versions

Synopsis

dotnet format [<PROJECT | SOLUTION>]
  [--binarylog <BINARY-LOG-PATH>] [--diagnostics <DIAGNOSTICS>]
  [--exclude <EXCLUDE>] [--exclude-diagnostics <EXCLUDE-DIAGNOSTICS>]
  [--include <INCLUDE>] [--include-generated]
  [--no-restore] [--report <REPORT-PATH>] [--severity <LEVEL>]
  [-v|--verbosity <LEVEL>] [--verify-no-changes] [--version]

dotnet format -h|--help

Description

dotnet format is a code formatter that applies style preferences and static analysis recommendations to a project or solution. Preferences will be read from an .editorconfig file, if present, otherwise a default set of preferences will be used. For more information, see the EditorConfig documentation.

Arguments

PROJECT | SOLUTION

The MSBuild project or solution to run code formatting on. If a project or solution file is not specified, MSBuild searches the current working directory for a file that has a file extension that ends in proj or sln, and uses that file.

[!CAUTION] dotnet format may restore, compile, and run analyzers from the specified project or solution. Only invoke the tool against trusted code.

Options

None of the options below are required for the dotnet format command to succeed, but you can use them to further customize what is formatted and by which rules.

-v|--verbosity <LEVEL>
Sets the verbosity level of the command. Allowed values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]. For more information, see <xref:Microsoft.Build.Framework.LoggerVerbosity>.
-?|-h|--help
Prints out a description of how to use the command.

Subcommands

Whitespace

dotnet format whitespace - Formats code to match editorconfig settings for whitespace.

Description

The dotnet format whitespace subcommand only runs formatting rules associated with whitespace formatting. For a complete list of possible formatting options that you can specify in your .editorconfig file, see the C# formatting options.

Options

Style

dotnet format style - Formats code to match EditorConfig settings for code style.

Description

The dotnet format style subcommand only runs formatting rules associated with code style formatting. For a complete list of formatting options that you can specify in your editorconfig file, see Code style rules.

Options

Analyzers

dotnet format analyzers - Formats code to match editorconfig settings for analyzers (excluding code style rules).

Description

The dotnet format analyzers subcommand only runs formatting rules associated with analyzers. For a list of analyzer rules that you can specify in your editorconfig file, see Quality rules.

Options

Examples

Info

2026-08-28 .NET Documentation