Emscripten turns C and C++ into WebAssembly via LLVM and Binaryen. Output runs in browsers, Node.js, and other WebAssembly runtimes.
Overview
Emscripten is a compiler toolchain that lowers C and C++ programs to WebAssembly. It relies on LLVM for translation and Binaryen as part of the pipeline, then bundles loadable WebAssembly with JavaScript glue so the result can execute outside native binaries.
Typical use starts with the emcc driver, invoked much like gcc or clang. The build produces a WebAssembly module plus JavaScript that loads and runs it in a browser, Node.js, Deno, or Bun. It can also emit a sample HTML page, served with the emrun helper or any static web server.
Beyond plain compilation, Emscripten ships shims for portable APIs such as OpenGL and SDL2, which helps bring graphical native software to the web. The project cites ports including the Unity engine and Google Earth as examples of what can be moved. While C and C++ via Clang are the main focus, other LLVM-based toolchains can integrate; Rust targets wasm32-unknown-emscripten are mentioned.
Installation is commonly done through the Emscripten SDK (emsdk), with manual setup from a source checkout as an alternative. The toolchain is meant for developers porting existing codebases to WebAssembly rather than as an end-user application on its own.
Key features
- C and C++ to WebAssembly compilation
- LLVM and Binaryen-based pipeline
- JavaScript loader generation
- OpenGL and SDL2 portability layers
- Sample HTML output and emrun serving
- Emscripten SDK (emsdk) installer
- Rust wasm32-unknown-emscripten integration
- Runs in browser and Node.js runtimes
Use cases
- Porting native C/C++ apps to the web
- Running compiled code in Node.js
- Graphical apps via SDL2 and OpenGL shims
- Game engine and mapping software ports
- Integrating other LLVM language front ends