The WebAssembly Binary Toolkit
WABT (we pronounce it "wabbit") is a suite of tools for WebAssembly, including:
These tools are intended for use in (or for development of) toolchains or other systems that want to manipulate WebAssembly files. Unlike the WebAssembly spec interpreter (which is written to be as simple, declarative and "speccy" as possible), they are written in C/C++ and designed for easier integration into other systems. Unlike Binaryen these tools do not aim to provide an optimization platform or a higher-level compiler target; instead they aim for full fidelity and compliance with the spec (e.g. 1:1 round-trips with no changes to instructions).
Wabt has been compiled to JavaScript via emscripten. Some of the functionality is available in the following demos:
wasm-interp or spectest-interp| Proposal | flag | default | binary | text | validate | interpret | wasm2c |
|---|---|---|---|---|---|---|---|
| exception handling | --disable-exceptions |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| mutable globals | --disable-mutable-globals |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| nontrapping float-to-int conversions | --disable-saturating-float-to-int |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| sign extension | --disable-sign-extension |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| simd | --disable-simd |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| threads | --enable-threads |
✓ | ✓ | ✓ | ✓ | ||
| multi-value | --disable-multi-value |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| tail-call | --disable-tail-call |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| bulk memory | --disable-bulk-memory |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| reference types | --disable-reference-types |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| annotations | --disable-annotations |
✓ | ✓ | ||||
| memory64 | --disable-memory64 |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| multi-memory | --disable-multi-memory |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| extended-const | --disable-extended-const |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| relaxed-simd | --disable-relaxed-simd |
✓ | ✓ | ✓ | ✓ | ✓ | |
| custom-page-sizes | --enable-custom-page-sizes |
✓ | ✓ | ✓ | ✓ | ✓ | |
| compact-imports | --enable-compact-imports |
✓ | ✓ | ||||
| function-references | --enable-function-references |
✓ | ✓ | ✓ | ✓ | ||
| wide-arithmetic | --enable-wide-arithmetic |
✓ | ✓ | ✓ |
Clone as normal, but don't forget to get the submodules as well:
$ git clone --recursive https://github.com/WebAssembly/wabt
$ cd wabt
$ git submodule update --initThis will fetch the testsuite and gtest repos, which are needed for some tests.
You'll need CMake. You can then run CMake, the normal way:
$ mkdir build
$ cd build
$ cmake ..
$ cmake --build .This will produce build files using CMake's default build generator. Read the CMake documentation for more information.
NOTE: You must create a separate directory for the build artifacts (e.g.
build above). Running cmake from the repo root directory will not work
since the build produces an executable called wasm2c which conflicts with the
wasm2c directory.
Makefile (Linux and macOS)NOTE: Under the hood, this uses make to run CMake, which then calls
ninja to perform that actual build. On some systems (typically macOS), this
doesn't build properly. If you see these errors, you can build using CMake
directly as described above.
You'll need CMake and Ninja. If
you just run make, it will run CMake for you, and put the result in
out/clang/Debug/ by default:
Note: If you are on macOS, you will need to use CMake version 3.2 or higher
$ makeThis will build the default version of the tools: a debug build using the Clang compiler.
There are many make targets available for other configurations as well. They are generated from every combination of a compiler, build type and configuration.
gcc, clang, gcc-i686, emscriptendebug, releaseasan, msan, lsan, ubsan, fuzz, no-testsThey are combined with dashes, for example:
$ make clang-debug
$ make gcc-i686-release
$ make clang-debug-lsan
$ make gcc-debug-no-testsYou'll need CMake. You'll also need Visual Studio (2015 or newer) or MinGW.
Note: Visual Studio 2017 and later come with CMake (and the Ninja build system) out of the box, and should be on your PATH if you open a Developer Command prompt. See https://aka.ms/cmake for more details.
You can run CMake from the command prompt, or use the CMake GUI tool. See Running CMake for more information.
When running from the commandline, create a new directory for the build artifacts, then run cmake from this directory:
> cd [build dir]
> cmake [wabt project root] -DCMAKE_BUILD_TYPE=[config] -DCMAKE_INSTALL_PREFIX=[install directory] -G [generator]The [config] parameter should be a CMake build type, typically DEBUG or RELEASE.
The [generator] parameter should be the type of project you want to generate,
for example "Visual Studio 14 2015". You can see the list of available
generators by running cmake --help.
To build the project, you can use Visual Studio, or you can tell CMake to do it:
> cmake --build [wabt project root] --config [config] --target installThis will build and install to the installation directory you provided above.
So, for example, if you want to build the debug configuration on Visual Studio 2015:
> mkdir build
> cd build
> cmake .. -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_INSTALL_PREFIX=..\ -G "Visual Studio 14 2015"
> cmake --build . --config DEBUG --target installIf you want to add new keywords, you'll need to install
gperf. Before you upload your PR, please
run make update-gperf to update the prebuilt C++ sources in src/prebuilt/.
Some examples:
# parse test.wat and write to .wasm binary file with the same name
$ bin/wat2wasm test.wat
# parse test.wat and write to binary file test.wasm
$ bin/wat2wasm test.wat -o test.wasm
# parse spec-test.wast, and write verbose output to stdout (including the
# meaning of every byte)
$ bin/wat2wasm spec-test.wast -vYou can use --help to get additional help:
$ bin/wat2wasm --helpOr try the online demo.
Some examples:
# parse binary file test.wasm and write text file test.wat
$ bin/wasm2wat test.wasm -o test.wat
# parse test.wasm and write test.wat
$ bin/wasm2wat test.wasm -o test.watYou can use --help to get additional help:
$ bin/wasm2wat --helpOr try the online demo.
Some examples:
# parse binary file test.wasm, and type-check it
$ bin/wasm-interp test.wasm
# parse test.wasm and run all its exported functions
$ bin/wasm-interp test.wasm --run-all-exports
# parse test.wasm, run the exported functions and trace the output
$ bin/wasm-interp test.wasm --run-all-exports --trace
# parse test.json and run the spec tests
$ bin/wasm-interp test.json --spec
# parse test.wasm and run all its exported functions, setting the value stack
# size to 100 elements
$ bin/wasm-interp test.wasm -V 100 --run-all-exportsYou can use --help to get additional help:
$ bin/wasm-interp --helpSee wast2json.md.
See wasm2c.md
See test/README.md.
To build with the LLVM sanitizers,
Zero-sized literal output buffers cause out-of-bounds access
00002fd: error: memory may not be shared: threads not allowed
`compact imports` broken
(CVE-2026-90648) vulnerability in wasm2c: tail call to a local function uses an uninitialised module instance pointer
`HUGE_VAL` and `HUGE_VALF` are not constant expressions on AIX
Custom section (before …)/(after …) placement is parsed but ignored
Should libwabt.js and libwabt.wasm be published on npm?
Port wasm2c to binaryen
[Security] Out-of-bounds write in `MakeTypeBindingReverseMapping` via unchecked `local_index` from the binary `name` section
wat2wasm/wast2json: assertion failure (!IsReferenceWithIndex()) parsing a typed reference in a GC struct/array field