Introduction
WABT (pronounced "wabbit") is the official WebAssembly Binary Toolkit maintained by the WebAssembly community group. It provides a set of command-line tools for converting between the WebAssembly text format (WAT) and binary format (WASM), validating modules, inspecting binaries, and running simple interpreters.
What WABT Does
- Converts WebAssembly text format to binary (wat2wasm) and back (wasm2wat)
- Validates WebAssembly modules for spec compliance (wasm-validate)
- Disassembles and dumps WASM binaries for inspection (wasm-objdump)
- Decompiles WASM to a C-like pseudo-code (wasm-decompile)
- Interprets WASM modules without a browser (wasm-interp)
Architecture Overview
WABT is written in C/C++ with no external dependencies beyond the standard library. It includes a hand-written lexer and parser for WAT text, a binary reader/writer for WASM, and an IR that connects them. The interpreter executes WASM bytecode directly. All tools share the same internal module representation, ensuring consistent behavior.
Self-Hosting & Configuration
- Install via Homebrew, apt, or download prebuilt binaries from GitHub releases
- Build from source with CMake on Linux, macOS, or Windows
- Tools are standalone executables with no runtime dependencies
- Enable WASI support by building with -DWITH_WASI=ON
- JavaScript/WebAssembly port available for browser-based use (wabt.js)
Key Features
- Reference implementation aligned with the official WebAssembly specification
- Support for WASM proposals (multi-memory, exception handling, GC, threads)
- wasm-decompile produces readable pseudo-code from any WASM binary
- wasm-interp runs WASM modules from the command line for quick testing
- wabt.js enables WAT-to-WASM conversion directly in the browser
Comparison with Similar Tools
- Binaryen — Focuses on optimization and code generation; WABT focuses on format conversion
- wasm-tools (Bytecode Alliance) — Rust-based toolkit with similar goals; WABT is the C/C++ reference
- Wasmtime — A WASM runtime; WABT provides tooling rather than execution
- wasm-pack — Builds Rust projects to WASM; WABT works with raw WAT/WASM files
FAQ
Q: Is WABT the official WebAssembly toolchain? A: It is maintained under the WebAssembly GitHub organization and closely tracks the spec.
Q: Can WABT optimize WASM binaries? A: No, use Binaryen (wasm-opt) for optimization. WABT focuses on conversion and inspection.
Q: Does wasm-interp support WASI? A: Yes, when built with WASI support enabled.
Q: Can I use WABT in a browser? A: Yes, wabt.js compiles the toolkit to WebAssembly itself for in-browser use.