Why convert WASM to WAT?
WAT is the human-readable text form of WebAssembly. People convert a .wasm to .wat to read, audit or debug what a module actually does - its functions, imports and exports - since the binary itself is unreadable.
How to convert WASM to WAT
wasm-tools print OPEN-SOURCE
From the Bytecode Alliance toolkit, run wasm-tools print module.wasm -o module.wat to write the text format. Omit -o to print to stdout.
wasm2wat (WABT) OPEN-SOURCE
Using the WebAssembly Binary Toolkit, run wasm2wat module.wasm -o module.wat. Add --generate-names for readable function labels and -f to fold expressions.
About these formats
A .wasm file holds a compiled WebAssembly module: portable binary bytecode produced from languages like C, C++, or Rust and run at near-native speed. Most .wasm files are loaded by a web…
Open .WASM details →A .WAT file is associated with IBM Voice Type Languages Map, a misc file.
Open .WAT details →Quality & what to watch
- The conversion is faithful but not the original source: you see low-level WASM instructions, not the C/C++/Rust it was compiled from.
- Unnamed functions appear as numeric indices unless you pass a name-generating flag, making large modules hard to follow.
- Editing the WAT and re-assembling with wat2wasm is possible but easy to get wrong for anything non-trivial.
Frequently asked questions
Is wasm-to-wat lossless?
wasm-tools or wabt - which should I use?
Can I convert the WAT back to .wasm?
wat2wasm module.wat -o module.wasm (WABT) reassembles it into the binary.How do I get readable function names?
--generate-names to wasm2wat, or keep the name section in the original build.