C Compiler
Compile and run C code online with Clang 21 and stdin input. Your program is compiled to WebAssembly and runs in your browser, so the code stays on your device.
About the C Compiler
The online C Compiler builds your program with Clang 21 (C17) and runs it straight away, so you can test a function, check pointer arithmetic or practise for an exam without installing GCC or an IDE. The compiler itself runs in your browser as WebAssembly: your code is never uploaded.
Your code runs in an isolated Web Worker in your browser, so it never leaves your device.
How to use the C Compiler
- Write or paste a C program with a main() function.
- Put any input your program reads (scanf, fgets) in the stdin box.
- Click Run. The first run downloads the compiler (about 23 MB); later runs reuse it.
- Read compiler warnings and errors, then the program output and exit code.
Example
Input
#include <stdio.h>
int main(void) {
int n, sum = 0;
while (scanf("%d", &n) == 1) sum += n;
printf("Sum: %d\n", sum);
return 0;
}Result
Sum: 108
With "4 8 15" and "16 23 42" on two stdin lines. scanf returns EOF when the stdin box is used up, which ends the loop.
Common mistakes
- Waiting for keyboard input. There is no interactive terminal. Type everything the program reads into the stdin box before you click Run; once it is used up, scanf returns EOF and fgets returns NULL.
- Null pointers do not always crash. In WebAssembly, address 0 is ordinary memory, so reading through a NULL pointer returns garbage instead of a segmentation fault. Out-of-bounds access past the end of memory and stack overflows do stop the program with a runtime error.
- Files, sockets and threads. fopen, socket calls and pthread_create fail in the sandbox. Read data from stdin and keep the program single-threaded.
Works well with the C Compiler
- C++ Compiler: run the same program as C++ with the standard library containers.
- Number Base Converter: check bit masks and hex values your program prints.
- Text & Code Diff: compare the output with the expected answer.
Frequently asked questions
Which C standard and compiler are used?
Clang 21 with -std=c17 -O2 -Wall, linking the WASI C library (a musl-based libc) and the maths library. Code that compiles with GCC in C17 mode almost always compiles here too.
Why is the first run slower?
The Clang toolchain is downloaded once (about 23 MB compressed) and then cached by your browser. Later runs only compile and execute your code.
Is this GCC?
No, it is Clang, which accepts the same C syntax and almost all GCC extensions. Code written for gcc -std=c17 normally compiles unchanged; GCC-only flags are not needed.
Is my code sent to a server?
No. Both the compiler and your program run in your browser as WebAssembly, so the code and its input stay on your device.
Does it work offline?
After the first run the compiler is in your browser cache, so later runs work even on a slow connection. The page itself still needs to load.
Related tools
JavaScript Compiler
Run JavaScript online in an isolated browser sandbox. See console output, errors and execution time instantly, with top-level await and stdin input.
TypeScript Compiler
Compile and run TypeScript online. Your code is type-checked with the official compiler in strict mode, then runs in a sandboxed worker in your browser.
Python Compiler
Run Python 3 code online with the full standard library and stdin input. It runs in your browser with Pyodide (WebAssembly), so your code stays on your device.
PHP Compiler
Run PHP 8.4 code online and see the output instantly, with stdin input and mbstring. PHP runs in your browser with WebAssembly, so your code stays private.
C++ Compiler
Compile and run C++20 code online with Clang 21, libc++ and stdin input. Programs compile to WebAssembly and run in your browser, so your code stays private.