跳到主要内容

wasmedge validate CLI

After installation, users can execute the wasmedge validate command.

The wasmedge validate command loads a WebAssembly module and runs the validation phase, checking that the module conforms to the WebAssembly specification. It does not instantiate or execute the module. This is useful for verifying correctness of a WASM binary before deployment or execution.

$ wasmedge validate -h
USAGE
wasmedge validate [OPTIONS] [--] WASM_OR_SO

...

Options

The options of the wasmedge validate 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).

Example

Validating a correct module

We created the hand-written fibonacci.wat and used the wat2wasm tool to convert it into the fibonacci.wasm WebAssembly program. It exported a fib() function which takes a single i32 integer as the input parameter.

You can run:

wasmedge validate fibonacci.wasm

The output will be:

[2026-03-24 02:07:35.939] [info] Validation succeeded.

The exit code will be 0.

Validating an invalid module

We created the hand-written bad_validate.wat and used the wat2wasm tool to convert it into the bad_validate.wasm WebAssembly program. This module intentionally contains a type mismatch to demonstrate validation failure.

You can run:

wasmedge validate bad_validate.wasm

The output will be:

[2026-03-24 02:08:49.475] [error] validation failed: type mismatch, Code: 0x202
[2026-03-24 02:08:49.475] [error] Mismatched value type. Expected: i32 , Got: i64
[2026-03-24 02:08:49.475] [error] In instruction: end (0x08) , Bytecode offset: 0x00000026
[2026-03-24 02:08:49.475] [error] At AST node: expression
[2026-03-24 02:08:49.475] [error] At AST node: code segment
[2026-03-24 02:08:49.475] [error] At AST node: code section
[2026-03-24 02:08:49.475] [error] At AST node: module

The exit code will be 1.