Remove comments from
C code.
Remove comments from C source code and headers online. Strips //, /* */, and Doxygen blocks while preserving preprocessor directives and string literals.
.c filesBefore and after
Real-world C code on the left. The same code with every comment removed on the right.
/* Linked list implementation. */
#include <stdio.h>
#include <stdlib.h>
// Forward declaration
struct Node;
/**
* A doubly-linked node.
*/
typedef struct Node {
int value; // payload
struct Node *next; // next pointer
struct Node *prev; // prev pointer
} Node;
// Allocate a new node
Node *node_new(int value) {
Node *n = malloc(sizeof(Node)); /* allocate */
if (!n) return NULL;
n->value = value;
n->next = NULL;
n->prev = NULL;
return n; // ownership transferred
}#include <stdio.h>
#include <stdlib.h>
struct Node;
typedef struct Node {
int value;
struct Node *next;
struct Node *prev;
} Node;
Node *node_new(int value) {
Node *n = malloc(sizeof(Node));
if (!n) return NULL;
n->value = value;
n->next = NULL;
n->prev = NULL;
return n;
}Built for C specifically.
C codebases collect comments fast, header guards, license blocks, function-by-function descriptions, and the occasional commented-out experiment. When you're chasing a bug, sharing a minimal reproducible example, or compacting a learning project, comment-free code is faster to scan. Uncommenter understands C-specific edge cases like character literals ('//' as a string vs as a comment) and never disturbs your `#include` and `#define` lines.
- Single-line // and block /* */ comments removed
- Preprocessor directives (#include, #define) preserved
- String and character literals untouched
- Doxygen and standard block comments treated identically
- Auto-detected from .c and .h files
Strip comments in 30 seconds.
- 1
Open the tool
Head to uncommenter.com/tool. Nothing to install. Nothing to sign up for.
- 2
Paste your C code
Drop your .c file in, or paste code into the editor. Auto-detection picks up C from the extension or file content.
- 3
Click 'Remove Comments'
The parser walks every character with a real state machine, strings, regex, and other context-sensitive parts are detected and left alone.
- 4
Copy or download
Grab the cleaned output. Your code never left your browser.
C questions, answered.
Does it remove preprocessor directives?
+
No. #include, #define, #ifdef, and other preprocessor directives are language syntax, not comments. They are always preserved.
What about character literals like '//' ?
+
Character and string literals are tracked as separate states by the parser, so a '//' character literal or a "//" string literal is left intact.
Does it work on C++ headers (.hpp)?
+
Use the dedicated C++ landing page for .cpp/.hpp/.cxx files, it adds support for raw string literals (R"(...)") which C does not have.
Working in something else?
Plus 35+ more languages supported in the live tool , including HTML, YAML, Dockerfile, Terraform, Solidity, and more.
Try it on your C code now.
Free forever. No signup. No upload. Runs entirely in your browser.
Open uncommenter