A command-line tool to convert WebAssembly Text Format (WAT) files into JavaScript Uint8Array representation.
- Node.js (>=14.0.0)
- wasm-tools
npm install -g wat2tawat2ta <wat-file>Example:
$ cat example.wat
(module
(func (export "add") (param i32 i32) (result i32)
local.get 0
local.get 1
i32.add))
$ wat2ta example.wat
const wasmCode = new Uint8Array([0, 97, 115, 109, ...]);The output can be used directly in JavaScript code to instantiate a WebAssembly module:
const wasmCode = new Uint8Array([...]); // Output from wat2ta
WebAssembly.instantiate(wasmCode).then(obj => {
// Use the WebAssembly instance
});MIT