Code Beautifier (C, C++, C#, Java, PHP, Go, Rust, Kotlin, Swift, Dart)
Re-indent C, C++, C#, Java, PHP, Go, Rust, Kotlin, Swift or Dart code: K&R or Allman braces, 2/4 spaces or tabs, switch cases, one statement per line.
Lines are re-indented and braces moved; expressions, strings and comments are not rewritten. Preprocessor lines (#if) that split a block in two can throw the indentation off.
Code pasted from a forum, an email or an old project often arrives with mixed tabs and spaces, braces in random places and everything on one line. This beautifier re-indents C, C++, C#, Java, PHP, Go, Rust, Kotlin, Swift and Dart by their brace structure: it knows each language's strings (raw strings, verbatim strings, text blocks, interpolation), character literals and comments, so a { inside a string never shifts the indentation. Choose K&R or Allman braces, 2 or 4 spaces or tabs, how switch cases are indented, and whether each statement gets its own line.
How to use this tool
- Paste the code and choose its language.
- Pick the indentation (2 spaces, 4 spaces or tabs) and the brace style.
- Choose how case labels sit inside a switch and whether to split statements onto their own lines.
- Copy the formatted code.
Formula
indent of a line = indent unit × (open { blocks + open ( [ lines) at its start, after any leading } ) ]
Brackets inside strings, character literals and comments are ignored. A line that starts with a closing bracket is dedented before it is printed. Inside a switch, case labels get one level (or none, the Go and Swift convention) and the statements under them one more. Brackets opened on the same line count once, so foo(() => { indents its body by one level.
Example
In the sample C program the K&R setting pulls { up after main(…), the body gets 4 spaces, for( becomes for ( and ){ becomes ) {. Inside the switch, case 'a': total+=1;break; is split so that break; gets its own line under the case, and the { in case '{': and in the printf string are correctly ignored. The 17 messy lines come out as 17 evenly indented ones.
Frequently asked questions
Does it change what my code does?
It only changes whitespace and line breaks around braces and semicolons; tokens are never reordered or rewritten, and strings and comments are copied exactly. For Go it never moves { to its own line, because Go would insert a semicolon there.
Is this the same as clang-format, gofmt or Prettier?
No. Those tools parse the full language and also wrap long lines and align expressions. This one re-indents and tidies spacing, which is enough to make most pasted code readable; run your project's formatter for its exact house style.
Why is a line still indented strangely?
Usually a bracket is unbalanced, or #if/#else branches each open a brace. The notes say when brackets do not match.
Is my code uploaded?
No. Formatting runs in your browser.
Last updated:
Page address with these inputs: https://kakao.mobile/tools/code-beautifier/
Cite or embed this tool
kakaoCalc. (2026, November 8). Code Beautifier (C, C++, C#, Java, PHP, Go, Rust, Kotlin, Swift, Dart). https://kakao.mobile/tools/code-beautifier/
“Code Beautifier (C, C++, C#, Java, PHP, Go, Rust, Kotlin, Swift, Dart).” kakaoCalc, 8 Nov. 2026, kakao.mobile/tools/code-beautifier/.
Paste this code into your page. The widget runs in your visitors' browsers, shows no ads and keeps a link back to this page. Embedding terms