Exported add function
(module
(func $add (param $a i32) (param $b i32) (result i32)
local.get $a
local.get $b
i32.add)
(export "add" (func $add)))Tap Run to execute
main.wat · output appears here
Press Run to execute
Output streams here as your program runs.
WebAssembly Text format (WAT) is the human-readable representation of WebAssembly modules. While WebAssembly normally ships as a compact binary (.wasm), WAT expresses the same instructions using S-expression syntax, letting you read, write, and learn the low-level stack machine by hand. Modules declare functions, memories, globals, imports, and exports, and the format maps directly onto the binary opcodes a Wasm engine executes.
CompileBytes assembles WAT corresponding to the WebAssembly 1.0 (MVP) specification. WAT is typically converted to the binary format with tools like wat2wasm from the WebAssembly Binary Toolkit (WABT), then instantiated by a runtime. Working in WAT is useful for understanding how compilers target Wasm, debugging generated output, and exploring core concepts like linear memory, typed values, and the structured control flow that make WebAssembly portable and safe.
main.wat is the entry point for each run.
Use the Input panel to pipe standard input to your program when it needs data.
Run sends your code to a fresh hosted runtime and streams the result into the output panel.
Your draft stays in this browser, and Share creates a separate snapshot link.
(module
(func $add (param $a i32) (param $b i32) (result i32)
local.get $a
local.get $b
i32.add)
(export "add" (func $add)))(module
(func (export "answer") (result i32)
i32.const 42))(module
(func (export "sumTo") (param $n i32) (result i32)
(local $i i32)
(local $total i32)
(block $done
(loop $cont
(br_if $done (i32.gt_s (local.get $i) (local.get $n)))
(local.set $total
(i32.add (local.get $total) (local.get $i)))
(local.set $i (i32.add (local.get $i) (i32.const 1)))
(br $cont)))
local.get $total))(module
(memory (export "mem") 1)
(global $counter (mut i32) (i32.const 0))
(func (export "bump") (result i32)
(global.set $counter
(i32.add (global.get $counter) (i32.const 1)))
global.get $counter))(module
(func (export "max") (param $a i32) (param $b i32) (result i32)
(if (result i32) (i32.gt_s (local.get $a) (local.get $b))
(then (local.get $a))
(else (local.get $b)))))(module
(func $fac (export "fac") (param $n i32) (result i32)
(if (result i32) (i32.le_s (local.get $n) (i32.const 1))
(then (i32.const 1))
(else
(i32.mul
(local.get $n)
(call $fac (i32.sub (local.get $n) (i32.const 1))))))))(module
(func (export "average") (param $a f64) (param $b f64) (result f64)
(f64.div
(f64.add (local.get $a) (local.get $b))
(f64.const 2))))(module
(memory (export "mem") 1)
(func (export "roundTrip") (result i32)
(i32.store (i32.const 0) (i32.const 99))
(i32.load (i32.const 0))))(module
(func (export "abs") (param $x i32) (result i32)
(select
(i32.sub (i32.const 0) (local.get $x))
(local.get $x)
(i32.lt_s (local.get $x) (i32.const 0)))))The editor uses Monaco, the engine behind VS Code, with language-aware editing tools and familiar keyboard controls.
Type or paste your code into the editor, then click Run (or press Ctrl/Cmd + Enter) to execute it.
Output streams into the console panel, including runtime errors, exit status, and execution time.
Nothing to install and no account to create — code runs in an isolated hosted runtime.
Language-aware autocomplete and IntelliSense suggestions where the editor has a matching language service
Syntax highlighting, with native compiler and runtime errors shown in the console
Bracket matching, auto-indentation, code folding, and a minimap
Multi-cursor editing plus find & replace (Ctrl/Cmd + F)
Full undo/redo history and copy to clipboard
Built on Monaco — the same editor that powers VS Code
Run on demand, or turn on Auto-run to execute on every change
Stop long-running or infinite programs at any time
A real console shows standard output, errors, exit status, and execution time
Pass standard input (stdin) to your program from the Input panel — one value per line
Switch between light and dark themes
Adjust font size and other editor settings
Toggle side-by-side or top/bottom layouts
Enter distraction-free fullscreen mode
Generate a shareable link to your exact code in one click — no login needed
Your work autosaves to your browser, so you can pick up where you left off
Copy the active file to your clipboard
Run code: Ctrl/Cmd + Enter
Find & replace: Ctrl/Cmd + F
Open the full shortcut list from the keyboard icon in the toolbar
WASM (WAT) is one of 46 single-file compiler scratchpads. Each run submits only main.wat; local sibling-file imports are not enabled.
Linked-project languages (23): Node.js, TypeScript, Deno, Python, C, Go, Dart, Swift, Rust, Ruby, PHP, Java, Kotlin, C++, C#, Nim, Crystal, Haxe, Zig, Scala, D, Bun, Objective-C.
Single-file scratchpads (46): Matplotlib, NumPy, pandas, Haskell, Clojure, Perl, Lua, Tcl, jq, Raku, Elixir, Bash, Zsh, Nushell, R, Assembly (NASM), Julia, Octave, Groovy, PowerShell, Visual Basic .NET, Odin, Pascal, Lisp, Erlang, CoffeeScript, COBOL, BASIC, V, Racket, OCaml, Prolog, AWK, Emacs Lisp, Emojicode, Forth, F#, Fortran, Assembly (NASM64), Solidity, Mojo, Ada, WASM (WAT), Gleam, Shell Script (sh), Scheme.
Download file exports the active WASM (WAT) source file.