Skip to main content

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.

  1. -h|--help: Show the help messages. Will ignore the other arguments below.
  2. (Optional) --log-level: Set logging level. Valid values: off, trace, debug, info, warning, error, fatal. Default is info.
  3. (Optional) --forbidden-plugin: List of plugins to ignore.
  4. (Optional) WebAssembly proposals:
  5. 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 name section, 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>