wasm2wat
Convert WebAssembly binary files to WAT text
TLDR
Convert a file to the text format and display it to the console
Write the output to a given file
SYNOPSIS
wasm2wat [options...] <input.wasm> [<output.wat>]
PARAMETERS
--all-features
Enable all experimental features
--debug-names
Preserve and emit debug names from name section
--disable-all
Disable all experimental features
--enable-<feature>
Enable specific proposal feature (e.g., --enable-reference-types)
--fold-exprs
Fold constant expressions (default)
--help
Show usage help
--inline-imports
Inline imported functions/tables
--lowercase
Use lowercase for all names
--module
Emit module (not script)
--no-check
Skip input validation
--no-fold-exprs
Disable expression folding
--preserve-imports
Keep imports un-inlined
--print-ast
Debug: print parsed AST
--use-strict
Emit strict names ($func0 style)
--version
Print version
--with-names
Use names section if present
DESCRIPTION
wasm2wat is a command-line tool from the WebAssembly Binary Toolkit (WABT) that translates compiled WebAssembly (.wasm) binaries into the human-readable WebAssembly Text Format (.wat). WebAssembly is a portable, high-performance binary code format for the web and beyond, executed in browsers and standalone runtimes.
This tool is essential for developers debugging Wasm modules, inspecting generated code from compilers like Emscripten or Rust's wasm-bindgen, or manually editing modules. It disassembles the binary's structured format—sections like types, functions, exports, and imports—into s-expr or textual syntax, preserving semantics.
By default, it validates input and outputs to stdout or a file. Options allow customization: stripping debug info, inlining functions, folding expressions, or enabling features like reference types. It's lightweight, fast, and integrates into build pipelines, CI/CD, or ad-hoc analysis.
Common workflow: compile C/Rust to Wasm, then wasm2wat input.wasm for review before optimization or deployment. Supports MVP up to recent proposals, making it a staple in Wasm ecosystems.
CAVEATS
Requires WABT installation; input must be valid Wasm unless --no-check; limited to supported proposals; large modules may produce verbose output.
INSTALLATION
Linux: sudo apt install wabt (Ubuntu/Debian), sudo dnf install wabt (Fedora); build from source via ninja after git clone https://github.com/WebAssembly/wabt.
EXAMPLE
wasm2wat --debug-names input.wasm > output.wat
Disassembles with names preserved.
HISTORY
Part of WABT, launched ~2016 by Mozilla/Google WebAssembly teams during spec development; evolved with Wasm phases (MVP 2017, multi-value 2019+); current v1.0.35+ supports latest proposals.
SEE ALSO
wat2wasm(1), wasm-objdump(1), wasm-validate(1), wasm-decompile(1)


