jsonecho

C# Formatter

Indent C# code and put braces and statements on their own lines.

Loading the tool...

How to use C# Formatter

  1. Paste the C# code.
  2. Choose the indent, four spaces is the .NET convention.
  3. Copy the result.

About C# Formatter

This formatter re-indents C# code by its braces, breaks lines after statements and keeps strings, verbatim strings and comments untouched. It is meant for snippets: code pasted from a chat, a decompiler or a log, which has lost its layout.

It is a layout tool, not a full style enforcer. For a whole solution, use dotnet format or your IDE with an editorconfig file, which understand naming and using directives as well.

Frequently asked questions

Does it follow the Microsoft coding conventions?

It uses the usual layout: four-space indent, opening brace on the same line. For strict control use an .editorconfig with dotnet format.

Are strings and comments safe?

Yes. Regular, verbatim and interpolated strings and both comment types are skipped by the formatter.

Will it fix syntax errors?

No. It works on the text layout and does not compile the code.

What about long lines?

Lines are not wrapped. Statements stay on one line even if they are long.

More in Code Formatters

All tools →