55 stable releases

new 1.0.57 Feb 3, 2023
1.0.52 Nov 21, 2022
1.0.47 Jul 27, 2022
1.0.41 Jan 5, 2022
0.1.0 Sep 23, 2016

#17 in WebAssembly

Download history 81995/week @ 2022-10-15 57103/week @ 2022-10-22 49900/week @ 2022-10-29 45737/week @ 2022-11-05 64500/week @ 2022-11-12 39312/week @ 2022-11-19 45891/week @ 2022-11-26 38895/week @ 2022-12-03 46439/week @ 2022-12-10 38310/week @ 2022-12-17 16348/week @ 2022-12-24 29828/week @ 2022-12-31 40924/week @ 2023-01-07 38027/week @ 2023-01-14 41698/week @ 2023-01-21 39681/week @ 2023-01-28

165,967 downloads per month
Used in 179 crates (55 directly)

Apache-2.0 WITH LLVM-exception

13K SLoC


A Bytecode Alliance project

A Rust parser for the WebAssembly Text Format (WAT).

Crates.io version Download docs.rs docs docs.rs docs


Add wat to your Cargo.toml

$ cargo add wat

And then you can parse WAT to binary WebAssembly via:

// Parse from a file ...
let binary = wat::parse_file("./foo.wat")?;

// ... or a string
let wat = r#"
        (func $foo)

        (func (export "bar")
            call $foo
let binary = wat::parse_str(wat)?;

AST Representation

The wat crate does not expose an AST as its goal is to provide a forever-stable interface against the wast crate. Using wat is suitable when all you want to do is translate from text-to-binary, for example parsing the input of a CLI program into the WebAssembly binary format.

If instead you're interested in working with the AST of a text file or otherwise adding your own parsing to the text format you'll want to take a look at the wast crate.

Stability and WebAssembly Features

Consult the crate documentation for more information, but the general idea is this crate will not issue a semver-breaking change for breaking changes in the WAT format, either for MVP features or post-MVP features. No opt-in is required to use WebAssembly features, so using them may break if the upstream spec changes.


This project is licensed under the Apache 2.0 license with the LLVM exception. See LICENSE for more details.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.


~10K SLoC