Skip to content
A simple event-driven library for parsing WebAssembly binary files
Rust Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows Use actions/checkout@v1 to support submodules checkout (#154) Dec 3, 2019
benches Fix mutable global validation Aug 19, 2019
examples Multi value (#103) Jun 24, 2019
testsuite @ 6d29716
.rustfmt.toml Add a minimal .rustfmt.toml so that IDEs know to apply rustfmt. Sep 28, 2018
LICENSE Change wasmparser's license to "Apache-2.0 WITH LLVM-exception". Oct 9, 2018 Make it a Bytecode Alliance project (#136) Nov 12, 2019 Make it a Bytecode Alliance project (#136) Nov 12, 2019

The WebAssembly binary file decoder in Rust

A Bytecode Alliance project

Build Status link

The decoder library provides lightweight and fast decoding/parsing of WebAssembly binary files.

The other goal is minimal memory footprint. For this reason, there is no AST or IR of WebAssembly data.

See also its sibling at


The documentation and examples can be found at the


use wasmparser::WasmDecoder;
use wasmparser::Parser;
use wasmparser::ParserState;

fn get_name(bytes: &[u8]) -> &str {

fn main() {
  let ref buf: Vec<u8> = read_wasm_bytes();
  let mut parser = Parser::new(buf);
  loop {
    let state =;
    match *state {
        ParserState::BeginWasm { .. } => {
            println!("====== Module");
        ParserState::ExportSectionEntry { field, ref kind, .. } => {
            println!("  Export {} {:?}", get_name(field), kind);
        ParserState::ImportSectionEntry { module, field, .. } => {
            println!("  Import {}::{}", get_name(module), get_name(field))
        ParserState::EndWasm => break,
        _ => ( /* println!(" Other {:?}", state) */ )


To fuzz test, switch to a nightly Rust compiler and install cargo-fuzz:

cargo install cargo-fuzz

Then, from the root of the repository, run:

cargo fuzz run parse

If you want to use files as seeds for the fuzzer, add them to fuzz/corpus/parse/ and restart cargo-fuzz.

You can’t perform that action at this time.