C# Code Viewer

Paste C# source and read it back with line breaks around every brace and statement — formatting only, nothing is compiled or run.

What it does

This is a whitespace-only pretty printer. It inserts a line break and one indent step after every {, a line break after every ;, and a line break before every }, then removes the empty lines that leaves behind. It does not parse C#, so it has no concept of nesting depth, of namespace versus class scope, or of using directives — every block gets the same single indent.

Worked example

Input:

public class Greeter { public void Hi() { Console.WriteLine("hi"); } }

Output:

public class Greeter {
  public void Hi() {
  Console.WriteLine("hi");
}
}

Notice the inner method body is not indented a second level — the formatter does not track how deep it is.

C#-specific things to watch

When to use it

Making a one-file snippet from a chat, a gist, or a stack trace readable enough to scan for a missing brace or an obvious mistake before you paste it into an IDE. For real formatting use dotnet format, an EditorConfig, or your IDE's reformat command, which all understand C# syntax.

Does it compile or check types?

No. Nothing runs; it only rearranges whitespace.

Why is my interpolated string on three lines?

The { and } inside $"..." are treated like code braces. Rejoin them manually.

Can I pick a brace style or indent width?

No. It always uses two-space indent with the opening brace at the end of the line.

Is my code uploaded anywhere?

No. It stays in your browser.