Java Code Viewer

Paste Java and read it back with consistent line breaks around braces and statements. Formatting only — nothing is compiled.

What it does

The viewer inserts a newline and one indent after each {, a newline after each ;, and a newline before each }, then collapses the blank lines that creates. It does not parse Java, track nesting depth, or understand package, import, or class structure, so every brace level is indented the same single step.

Worked example

Input:

public class Main { public static void main(String[] args) { System.out.println("Hello"); } }

Output:

public class Main {
  public static void main(String[] args) {
  System.out.println("Hello");
}
}

Java-specific notes

When to use it

Turning a single pasted class or method from an email, a forum answer, or a stack trace into something scannable, or spotting an unbalanced block quickly. For project formatting use your IDE, google-java-format, or a Spotless / Checkstyle setup that actually parses the language.

Does it run or compile the code?

No. It only rewrites whitespace; the source is never executed.

Why is my for-loop split across three lines?

Each ; triggers a line break, including the two inside the loop header.

Does it enforce Google or Sun style?

No. It applies one fixed style: two-space indent, opening brace at line end.

Is my source uploaded?

No. Formatting happens in your browser.