The WebAssembly.validate() function validates a given typed array of WebAssembly binary code, returning whether the bytes form a valid wasm module (true) or not (false).




A typed array or ArrayBuffer containing WebAssembly binary code to be validated.

Return value

A boolean that specifies whether bufferSource is valid wasm code (true) or not (false).


If bufferSource is not a typed array or ArrayBuffer, a TypeError is thrown.


The following example (see the validate.html source code, and see it live too) fetches a .wasm module and converts it into a typed array. The validate() method is then used to check whether the module is valid.

fetch('simple.wasm').then(response =>
).then(function(bytes) {
  var valid = WebAssembly.validate(bytes);
  console.log("The given bytes are "
    + (valid ? "" : "not ") + "a valid wasm module");


Specification Status Comment
WebAssembly JavaScript Interface
The definition of 'validate()' in that specification.
Working Draft Initial draft definition.

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support5716522 No4411
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support5757 Yes1522 ?117.0

1. This feature is behind the Experimental JavaScript Features preference.

2. Disabled in the Firefox 52 Extended Support Release (ESR).

See also

Document Tags and Contributors

Contributors to this page: chrisdavidmills, fscholz, lukewagner
Last updated by: chrisdavidmills,