wasmedge parse CLI
After installation, users can execute the wasmedge parse command.
The wasmedge parse command loads a WebAssembly module and displays a detailed summary of its structure, including all sections defined in the binary (types, imports, functions, globals, exports, code, memory, tables, and custom sections). It is useful for inspecting WASM modules without executing them.
$ wasmedge parse -h
USAGE
wasmedge parse [OPTIONS] [--] WASM_OR_SO
...
Options
The options of the wasmedge parse command are as follows.
-h|--help: Show the help messages. Will ignore the other arguments below.- (Optional)
--log-level: Set logging level. Valid values:off,trace,debug,info,warning,error,fatal. Default isinfo. - (Optional)
--forbidden-plugin: List of plugins to ignore. - (Optional) WebAssembly proposals:
- Use
--wasm-1to set the environment as WASM 1.0 standard. This standard includes the following proposals: - Use
--wasm-2to set the environment as WASM 2.0 standard. This standard includes the WASM 1.0 and following proposals: - Use
--wasm-3to set the environment as WASM 3.0 standard (Currently default since 0.16.0). This standard includes the WASM 2.0 and following proposals: - Use
--disable-import-export-mut-globalsto disable the Import/Export of Mutable Globals proposal (DefaultON). - Use
--disable-non-trap-float-to-intto disable the Non-Trapping Float-to-Int Conversions proposal (DefaultON). - Use
--disable-sign-extension-operatorsto disable the Sign-Extension Operators proposal (DefaultON). - Use
--disable-multi-valueto disable the Multi-value proposal (DefaultON). - Use
--disable-bulk-memoryto disable the Bulk Memory Operations proposal (DefaultON). - Use
--disable-reference-typesto disable the Reference Types proposal (DefaultON). - Use
--disable-simdto disable the Fixed-width SIMD proposal (DefaultON). - Use
--disable-tail-callto disable the Tail call proposal (DefaultON). - Use
--disable-extended-constto disable the Extended Constant Expressions proposal (DefaultON). - Use
--disable-function-referenceto disable the Typed-Function References proposal (DefaultON). - Use
--disable-gcto disable the Garbage Collection proposal (DefaultON). - Use
--disable-multi-memoryto disable the Multiple Memories proposal (DefaultON). - Use
--disable-relaxed-simdto disable the Relaxed SIMD proposal (DefaultON). - Use
--disable-exception-handlingto disable the Exception Handling proposal (DefaultON). - Use
--enable-threadsto enable the Threads proposal (DefaultOFF). - Use
--enable-componentto enable the Component Model proposal (DefaultOFF, loader phase only). - Use
--enable-allto enable ALL proposals above.
- Use
- Input WASM file (
/path/to/wasm/file).
Output
The wasmedge parse command prints a structured summary of the WASM binary, organized by section:
- Type — Function signatures (parameter and return types).
- Import — Imported functions, memories, tables, and globals with their source module and name.
- Function — Locally defined functions with their type signature index.
- Global — Global variables with type, mutability, and initializer expression.
- Export — Exported functions, globals, memories, and tables.
- Code — Code segments with byte sizes for each function.
- Custom — Custom sections such as the
namesection, which maps indices to human-readable names.
If a name custom section is present in the WASM binary, function and global names will be displayed alongside their indices throughout the output.
Example
We created the hand-written parse_example.wat and used the wat2wasm tool to convert it into the parse_example.wasm WebAssembly program. It contains imports, multiple function signatures, globals with initializers, and a name custom section.
You can run:
wasmedge parse parse_example.wasm
The output will be:
parse_example.wasm: file format wasm 0x1
Section Details:
Type[5]:
- type[0] (i32, i32) -> nil
- type[1] () -> nil
- type[2] (i32, i32) -> i32
- type[3] (i64) -> i64
- type[4] () -> f64
Import[4]:
- memory[0] pages: initial=2 max=16 <- env.memory
- func[0] sig=0 <log> <- env.log
- table[0] <- env.table
- global[0] i32 mutable=0 <imported_base> <- env.base
Function[7]:
- func[1] sig=1 <__wasm_call_ctors>
- func[2] sig=2 <add>
- func[3] sig=2 <sub>
- func[4] sig=2 <mul>
- func[5] sig=3 <factorial>
- func[6] sig=4 <get_pi>
- func[7] sig=0 <call_log>
Global[5]:
- global[1] i32 mutable=1 <__stack_pointer> - init i32=66560
- global[2] i32 mutable=0 <__heap_base> - init i32=131072
- global[3] i32 mutable=0 <__data_end> - init i32=1024
- global[4] f64 mutable=0 <pi_approx> - init f64=3.14159
- global[5] i64 mutable=0 <big_val> - init i64=9999999999
Export[13]:
- func[1] <__wasm_call_ctors> -> "__wasm_call_ctors"
- func[2] <add> -> "add"
- func[3] <sub> -> "sub"
- func[4] <mul> -> "mul"
- func[5] <factorial> -> "factorial"
- func[6] <get_pi> -> "get_pi"
- func[7] <call_log> -> "call_log"
- global[1] -> "__stack_pointer"
- global[2] -> "__heap_base"
- global[3] -> "__data_end"
- global[4] -> "pi_approx"
- global[5] -> "big_val"
- table[1] -> "func_table"
Code[7]:
- func[1] size=2 <__wasm_call_ctors>
- func[2] size=7 <add>
- func[3] size=7 <sub>
- func[4] size=7 <mul>
- func[5] size=39 <factorial>
- func[6] size=11 <get_pi>
- func[7] size=8 <call_log>
Custom:
- name: "name"
- func[0] <log>
- func[1] <__wasm_call_ctors>
- func[2] <add>
- func[3] <sub>
- func[4] <mul>
- func[5] <factorial>
- func[6] <get_pi>
- func[7] <call_log>
- global[0] <imported_base>
- global[1] <__stack_pointer>
- global[2] <__heap_base>
- global[3] <__data_end>
- global[4] <pi_approx>
- global[5] <big_val>