C / C++ Formatter — Reindent C & C++ with Brace Controls
Reindent only — not a full formatterReindent C or C++ source — brace style, indent width, and preprocessor placement controls. Indentation tidy, not a full clang-format.
How to use
- 1 Pick C or C++.
- 2 Paste source.
- 3 Pick brace style, indent size, and where preprocessor lines should sit.
- 4 Copy or download the result.
Why use this tool
- Astyle-equivalent rule set: braces, indent, preprocessor placement.
- Preprocessor lines can stay at column 0 or follow nesting — your call.
- Pure client-side — your code never leaves the browser.
- For canonical output use clang-format locally with your .clang-format file.
Frequently asked questions
Does this match clang-format?
Approximate — we apply indent and brace style only. clang-format also handles pointer alignment, column-limit wrapping, and access-modifier indent. Use clang-format locally for canonical output.
C vs C++ — what changes?
The rule set is shared. The toggle controls which sample we load and which extension the download uses.
Will it preserve my macros?
Macro definitions on preprocessor lines are kept verbatim. Multi-line macros with trailing backslash are kept on consecutive lines but each is treated as one preprocessor line.
What is C / C++ Formatter?
A C / C++ Formatter is a tool that reindents C or C++ source code in the browser with controls for brace style, indent width, and preprocessor directive placement. It works as an indentation tidier rather than a full clang-format, applying consistent layout without compiling and keeping the source client-side.
Features
Brace-depth reindent
Re-indents functions and blocks by nesting, with K&R or Allman brace placement.
Preprocessor-aware
Leaves #include / #define directives at column zero instead of indenting them.
100% private
Runs on your device — your source is never uploaded.
Example
Input
#include <stdio.h>
int main() {
printf("hi");
return 0;
}
Output
#include <stdio.h>
int main() {
printf("hi");
return 0;
}
Common use cases
-
1
Fix pasted C/C++
Repair indentation on code copied from a textbook, PDF, or forum.
-
2
Normalize brace style
Convert a block between K&R and Allman placement.
-
3
Quick tidy
Clean up layout without a local clang-format setup.
Zerethon's C / C++ formatter reindents source in your browser by brace depth while keeping preprocessor directives (`#include`, `#define`) at column zero, with a K&R or Allman brace toggle. It is a lightweight reindenter, not a full clang-format — it tidies layout without reflowing code. Nothing is uploaded.
- Category
- Developer
- Pricing
- Free
- Privacy
- Browser-based
- Signup
- Not required
References
- cppreference.com — C / C++ reference — cppreference
- Google C++ Style Guide — Google
Privacy
Your data never leaves your browser unless explicitly stated. C / C++ Formatter runs entirely client-side — no server upload, no logging, no tracking of your input.
Related tools
JSON Formatter
Format, validate, and minify JSON online. Free, no signup — your data never leaves your browser.
Open toolSQL Formatter
Format SQL queries online — beautify MySQL, PostgreSQL, SQLite, SQL Server, Oracle, and BigQuery.
Open toolUUID Generator
Generate UUIDs online — v1, v4, v7, and Nil. Bulk generation up to 10,000. Free, no signup.
Open toolPassword Generator
Generate strong, cryptographically random passwords. Configurable length and character sets — runs in your browser.
Open toolBuild, share, and grow on Zerethon Social
Free signup. Earn points, collect achievements, and connect with creators worldwide.