wasm2c
Convert WebAssembly to portable C code
TLDR
Convert to C
SYNOPSIS
wasm2c [-o output] [--header file] [options] input
DESCRIPTION
wasm2c is a tool from the WABT (WebAssembly Binary Toolkit) that translates WebAssembly binary modules into portable C source code. The generated C code can be compiled with any standard C compiler, enabling WebAssembly modules to run natively without a WebAssembly runtime.
The tool produces both a C source file containing the translated module logic and an optional header file with function declarations and type definitions. A custom module name can be specified to control the naming of generated symbols, which is useful when linking multiple translated modules together.
This approach is useful for embedding WebAssembly functionality in C/C++ projects, running WebAssembly on platforms without a runtime, or analyzing module behavior through the generated source code.
PARAMETERS
-o FILE
Output C file.--header FILE
Generate header.--module-name NAME
C module name.--help
Show help.
CAVEATS
Generated code large. Slow compilation. Part of WABT.
HISTORY
wasm2c is part of WABT (WebAssembly Binary Toolkit), converting WebAssembly to portable C code.
