b2KIT

C# Formatter

Format C# source code with proper namespace indentation, brace style, and member ordering.

Tested tool guide Tested browser tools Checked August 16, 2026

What C# Formatter does and how it behaves

C# Formatter rewrites pasted C# source into a consistent layout, correcting indentation inside block-scoped namespaces, applying its brace style, and arranging type members in its expected order. It is useful when code is valid but visually inconsistent or difficult to review. The important surprise is that member ordering can move declarations, so the result may contain more than whitespace changes. Review the formatted output before replacing production source, particularly when declaration order could affect initialization behavior.

How the result is produced

1

Namespace and brace layout

The formatter identifies C# namespace and type structure, then adjusts indentation to reflect that nesting. It also normalizes brace placement around constructs such as namespaces, classes, methods, properties, and control-flow blocks. The result expresses the formatter's selected C# layout; it does not establish that the same brace or indentation choices are required by the language.

2

Member arrangement

Declarations within a C# type are arranged according to the formatter's member-ordering rules. This can make a class with intermixed fields, constructors, properties, and methods easier to scan, but it is a structural rewrite rather than a purely cosmetic whitespace pass. Compare declaration positions when reviewing the result, instead of checking indentation alone.

Good uses

  • Normalize namespace indentation and brace placement in a C# snippet copied from a poorly formatted source.
  • Prepare a class for review when its fields, constructors, properties, and methods are intermixed.
  • Make several C# examples follow one visible layout before placing them in documentation or a code discussion.

Limits and checks

  • Formatted C# is not necessarily compilable C#. This tool presents source consistently but does not prove that names, types, syntax, or control flow are correct.
  • Do not assume the output differs only in whitespace. Member ordering can relocate declarations, so inspect the resulting diff before replacing an existing file.
  • The selected brace and namespace indentation style may differ from a repository's .editorconfig or team conventions. A clean result is not proof of project-style compliance.

Common questions

Will C# Formatter fix compiler errors?

No. Its purpose is source layout: namespace indentation, brace style, and member ordering. Formatting cannot resolve an unknown identifier, an incompatible type, an inaccessible member, or incorrect program logic. Compile the result with the target project's compiler and dependencies when you need confirmation that the code is valid.

Will the result match dotnet format or my project's .editorconfig?

Not necessarily. This formatter applies its own visible namespace, brace, and member-ordering behavior to the pasted source. Project formatters can use repository-specific C# options that select different indentation or brace conventions. If exact project conformity matters, compare the output with the formatter configured for that repository before committing it.

References and verification

The behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools