Skip to content

Tooling

Shipping efficient WebAssembly starts well before you write a single instruction. You need tools to convert .wat text into .wasm binary, to inspect what is inside a compiled module, and to shrink the bytes before they go over the network. Three projects cover almost every need: wabt, Binaryen, and wasm-tools.

Tool familyMaintained byCore strength
wabt (WebAssembly Binary Toolkit)WebAssembly CGWAT ↔ binary conversion, validation, inspection
BinaryenGoogle / EmscriptenOptimisation and code generation, wasm-opt
wasm-toolsBytecode AllianceRust-based suite: parse, validate, compose, encode

Each family occupies a distinct stage in the pipeline. The diagram below shows how a .wat source file travels through these tools on its way to a deployed, optimised module.

flowchart LR
  A[".wat source"] -->|"wat2wasm"| B[".wasm binary"]
  B -->|"wasm-opt -O3"| C["optimised .wasm"]
  C -->|"wasm2wat / wasm-objdump"| D["inspection / debug"]
  B -->|"wasm-validate"| E["validation report"]
  B -->|"wasm-tools parse"| F["structured analysis"]
WAT → .wasm → optimised → inspect

wabt is the official reference implementation of the WAT text format. Its flagship binary is wat2wasm, which converts a .wat file into a .wasm binary. The reverse direction — disassembling a .wasm back to human-readable WAT — is handled by wasm2wat. Two companion tools round out the package: wasm-objdump prints the section headers and symbol table of any binary, and wasm-validate checks whether a module conforms to the specification.

Terminal window
# Install via npm (works without a native build)
npm install -g wabt
# Compile WAT to binary
wat2wasm add.wat -o add.wasm
# Disassemble back to text
wasm2wat add.wasm -o add.wat
# Inspect section headers
wasm-objdump -x add.wasm
# Validate a module
wasm-validate add.wasm

Binaryen is an optimising compiler infrastructure for WebAssembly. Its user-facing tool is wasm-opt, which rewrites a .wasm binary to produce a smaller or faster output. Emscripten, AssemblyScript, and wasm-pack (for Rust) all call wasm-opt automatically as part of their release builds — you benefit even if you never invoke it directly.

Terminal window
# Install
npm install -g binaryen
# Speed-optimise (prefer fast execution)
wasm-opt -O3 input.wasm -o output.wasm
# Size-optimise (prefer small download)
wasm-opt -Oz input.wasm -o output.wasm

wasm-tools is the Bytecode Alliance’s next-generation suite, written in Rust and available as both a CLI and a library. It supports the WebAssembly Component Model proposals, composing multiple modules together, stripping custom sections, and encoding/decoding the binary format with spec-level accuracy.

Terminal window
# Install
cargo install wasm-tools
# Validate
wasm-tools validate add.wasm
# Print text format
wasm-tools print add.wasm
# Strip custom sections (removes debug info)
wasm-tools strip add.wasm -o add.stripped.wasm
Which tool converts a .wat text file into a .wasm binary?
Which tool family is primarily focused on size and speed optimisation?
Which organisation maintains the wasm-tools project?
What does wasm2wat do?