WebAssembly Text Format
WebAssembly Text Format (WAT, or WAST) is a human-readable, S-expression-based textual representation of WebAssembly's binary instruction format, used for writing, reading, and debugging WebAssembly modules directly. wasm format that…
Definition
WebAssembly Text Format (WAT, or WAST) is a human-readable, S-expression-based textual representation of WebAssembly's binary instruction format, used for writing, reading, and debugging WebAssembly modules directly. It maps one-to-one with the compact binary .wasm format that browsers and runtimes actually execute.
Overview
WebAssembly (Wasm) is primarily distributed and executed as a compact binary format (.wasm) designed for fast parsing and small file size, which makes it efficient for browsers and other runtimes to load but effectively unreadable to humans. The WebAssembly Text Format exists as the standardized textual counterpart to that binary format, using a Lisp-like S-expression syntax to represent the same module structure — functions, types, imports, exports, memory, and instructions — in a form developers can read, write, and reason about directly. Every valid .wasm binary module can be losslessly converted to and from its .wat textual representation using standard tooling, most commonly the WebAssembly Binary Toolkit (WABT), which provides the wat2wasm and wasm2wat converters, as well as browser developer tools that can display disassembled Wasm as WAT. In practice, very few developers hand-write large WAT programs, since most WebAssembly is produced by compiling from higher-level languages like C, C++, Rust, or Go; WAT is instead primarily used for debugging (inspecting what a compiler actually generated), writing small hand-optimized modules or test cases, teaching the low-level semantics of the WebAssembly instruction set, and generating Wasm programmatically from tools that emit text before assembling it to binary. WAT's syntax reflects WebAssembly's stack-based virtual machine model directly: instructions like i32.add, local.get, and call appear explicitly, and functions, tables, and memories are declared with explicit type signatures. Because WAT is a direct, spec-defined mapping of the binary format rather than a higher-level language, it has no abstractions like variables with inferred types, control-flow sugar, or standard library — it exposes exactly the primitives the WebAssembly virtual machine executes, making it closer in spirit to an assembly language than to a general-purpose programming language.
Key Features
- S-expression-based syntax representing WebAssembly modules as human-readable text
- Losslessly convertible to and from the binary .wasm format
- Standardized as part of the WebAssembly specification itself
- Directly exposes the stack-based instruction set of the Wasm virtual machine
- No high-level abstractions — a near 1:1 mapping to binary opcodes
- Supported by tooling like WABT (wat2wasm/wasm2wat) and browser devtools
- Used primarily for debugging, teaching, and hand-written low-level modules
- Rarely hand-written for large programs; usually generated by compilers or disassemblers
Use Cases
Alternatives
Frequently Asked Questions
From the Blog
Generative AI Explained: From Text to Images
Generative AI creates new content from patterns it learned — understand how text generation, image synthesis, and more work.
Read More ProgrammingRegular Expressions in Python: A Practical Guide
Regular expressions are one of the most powerful text-processing tools in programming — and one of the most avoided, because the syntax looks intimidating. This guide demystifies regex by building from first principles, with real patterns for emails, phone numbers, dates, and log parsing.
Read More ProgrammingPython File I/O: Reading and Writing Files
Almost every real Python program reads or writes files — logs, configs, CSVs, JSON, reports. This guide covers text files, CSV, JSON, binary files, and the modern pathlib approach, with best practices for safe file handling.
Read More AI & TechnologyLarge Language Models (LLMs) Explained for Beginners
An LLM predicts the next piece of text, one token at a time — this guide explains how ChatGPT, Claude, and Gemini actually work.
Read More