Skip to main content

WAT to WASM Converter

Write, validate, and explore WebAssembly Text Format (WAT). Includes syntax highlighting, module structure analysis, 5 example snippets, and toolchain commands.

✓ WAT syntax highlighting ✓ Module structure analysis ✓ 5 example snippets ✓ wat2wasm commands

Frequently Asked Questions

What is WAT (WebAssembly Text Format)?▼

WAT is the S-expression based human-readable text representation of WebAssembly. Every .wasm binary has an equivalent .wat form that can be round-tripped via the wabt toolchain. WAT uses parenthesized expressions like (func $add (param i32 i32) (result i32) ...) to describe modules. It's the primary format for hand-authoring small WASM modules, debugging disassembled binaries, and learning WASM internals.

How do I compile WAT to a WASM binary?▼

Install wabt (WebAssembly Binary Toolkit): 'npm install -g wabt' or 'brew install wabt'. Then run: wat2wasm module.wat -o module.wasm. To go the other direction (disassemble): wasm2wat module.wasm -o module.wat. You can also validate without producing output: wat2wasm module.wat --output=-. The online wat.js project lets you compile WAT in the browser via JavaScript.

What are the WASM value types?▼

WebAssembly MVP supports four value types: i32 (32-bit integer), i64 (64-bit integer), f32 (32-bit float), f64 (64-bit float). The post-MVP additions include v128 (128-bit SIMD vector), funcref (function reference), and externref (host object reference). There is no boolean type — conditions use i32 where 0 is false and non-zero is true. Strings are not a native type; they're stored in linear memory as UTF-8 bytes.

What is the WASM stack machine model?▼

WebAssembly uses a stack-based virtual machine. Instructions push values onto and pop values off an implicit stack. For example, 'i32.add' pops two i32 values from the stack and pushes their sum. 'local.get $x' pushes the value of local variable $x. Function parameters and locals are indexed. The WAT text format also supports a folded (S-expression) notation that looks more like a tree: (i32.add (local.get $a) (local.get $b)).

How does linear memory work in WASM?▼

WASM linear memory is a contiguous, byte-addressable buffer (WebAssembly.Memory). It starts at a specified size (in 64KB pages) and can grow with memory.grow. You declare it as (memory 1) for one 64KB page. JavaScript can read/write it via typed arrays on the buffer: new Uint8Array(instance.exports.memory.buffer). The (data ...) instruction initializes memory at module load. Pointers in WASM are just i32 byte offsets into this linear address space.

Share this tool: X / Twitter LinkedIn
✓ 60,000+ developers use DevPlaybook ★★★★★ 4.8 / 5 on Gumroad ✓ MIT licensed · Instant download ✓ No login required

Related Products

on Gumroad

You Might Also Need

More Free Tools

Enjoying this tool? Get more like it.

Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.

DevPlaybook Pro 7 days free

Unlock AI-Powered Dev Tools

  • ⚡ AI Code Review, Doc Generator & SQL Builder
  • ⚡ All premium templates & early access
  • ⚡ Member discounts on Gumroad products
Start Free Trial →

$9/mo after trial · Cancel anytime

Want the full toolkit?

Get DevPlaybook Pro

Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.

$79
$241 separately Save $162 (67% off)
Get DevPlaybook Pro — $79 →

MIT licensed · Instant download · No subscription

See what's included → Browse all deals →