This page follows design/mvp/Binary.md of the
component-model repository
(branch main, read 2026-11-18), with meanings and validation rules from
Text.md in the same folder. Values such as u32 (unsigned LEB128),
name (a u32 length and UTF-8 bytes) and vec(T) (a
u32 count and that many T) are the core WebAssembly encodings,
described on the core module page. A mark
such as 🔀 is the specification’s gate: the feature is not part of the stable WASI 0.2
set; see the status table for what each
mark means. Binary.md states that it is not a complete definition of decoding
and validation, so the validity rules below are the ones it lists.
Preamble
| Offset | Size | Field | Value |
|---|---|---|---|
0 | 4 | magic | 00 61 73 6D (\0asm), the same as a core module |
4 | 2 | version | 0D 00 (0x000d, little-endian). Pre-standard: bumped upwards as the proposal changes, and to be set to 0x1 when the standard is final. |
6 | 2 | layer | 01 00 (0x0001). Distinguishes components from modules early in the file. |
A core module has 01 00 00 00 at offset 4. Read as two 16-bit fields that is
version 1 and layer 0, which is why a component can use layer 1. Binary.md
notes that this needs a backward-compatible change to the core specification, to split the
core version field and fix its layer at 0 for ever.
| Bytes 4 to 7 | Format |
|---|---|
01 00 00 00 | a core module (version 1, layer 0) |
0D 00 01 00 | a component (version 0x0d, layer 1), described here |
| anything else | not defined by the sources read for these pages |
The grammar is component ::= preamble section*. A component embedded in
another (section 4) is a whole component and so starts with its own
preamble; a core module in section 1 starts with the core module preamble.
Sections
After the preamble come sections, each:
| Field | Encoding | Meaning |
|---|---|---|
| id | byte | Section ID, below. |
| size | u32 | Length of the contents in bytes (the core section frame, section_N(B) in the grammar). |
| contents | size bytes | Depends on the ID. |
| ID | Section | Contents | Adds to | Gate |
|---|---|---|---|---|
0 | custom | a core custom section: name, then bytes | nothing | |
1 | core module | one complete core module (with its preamble) | core module index space | |
2 | core instance | vec(core:instance) | core instance | |
3 | core type | vec(core:type) | core type | |
4 | component | one complete component (with its preamble) | component | |
5 | instance | vec(instance) | instance | |
6 | alias | vec(alias) | the space of each alias’s sort | |
7 | type | vec(type) | type | |
8 | canon | vec(canon) | func (lift) or core func (lower and the built-ins) | |
9 | start | one start definition | value (its results) | 🪙 |
10 | import | vec(import) | the space of each import’s sort | |
11 | export | vec(export) | the space of each export’s sort | |
12 | value | vec(value) | value | 🪙 |
The AST each section produces is shown in the grammar (for example a core instance
becomes (core instance …)): the ID selects the kind of definition and the
“adds to” column is the index space that definition is appended to. Unlike a core
module there is no required order and no limit on how often an ID occurs, since
definitions are interleaved in the text format and are “strictly acyclic”: a definition
may only refer to indices introduced by definitions before it. Components form trees:
sections 1 and 4 hold whole modules and components, and all other definitions are
leaves.
Section 0 is the core custom section and produces no definition, so it has no effect
on validation. The component model defines one custom section,
component-name.
Source-read, not in the specification text: the component-model files define no other
custom section and say nothing about the custom sections of the WebAssembly tool conventions at component
level. The wasmparser crate of wasm-tools (crates/wasmparser/src/readers/core/custom.rs,
CustomSectionReader::as_known, main branch, raw, fetched 2026-11-19) picks the known kinds by the
section’s name, the same code for a module and a component: name,
component-name (when built with component-model support), metadata.code.branch_hint,
producers, dylink.0, the coredump sections (core,
coremodules, coreinstances, corestack), linking and
reloc.*; every other name is unknown, and for several of the kinds (branch hints, producers, the coredump
sections, linking, reloc) a section whose start does not parse is treated as unknown too. That is how one decoder behaves, not a rule of the format. No component file
carrying such sections was examined for these pages.
Sorts and index spaces
There are 13 index spaces, one per sort: 5 at component level (components, component
instances, functions, types and, with 🪙, values), 6 that already exist in core
WebAssembly (functions, tables, memories, globals, tags and types) and 2 more core ones
(modules and module instances) that are not in the core specification at present. Each
definition appends to an index space and later definitions refer to it by u32
index. A sortidx is a sort followed by an index.
| Encoding | core:sort | Notes |
|---|---|---|
00 | func | These values are chosen to match the opcodes of the core externtype. |
01 | table | |
02 | memory | |
03 | global | |
04 | tag | |
10 | type | Added in anticipation of the type-imports proposal. Core modules cannot import or export types yet; the sort is allowed in outer aliases. |
11 | module | Added in anticipation of the module-linking proposal; useful for aliases. |
12 | instance | As for module. |
| Encoding | sort | Gate |
|---|---|---|
00 then a core:sort | core, with that core sort (two bytes: 00 02 is core memory) | |
01 | func | |
02 | value | 🪙 |
03 | type | |
04 | component | |
05 | instance |
core:sortidx is a core:sort byte and a u32; sortidx is a
sort and a u32. Indices are validated against the index space of their sort,
which is built up incrementally as each definition is validated.
Core module (1)
The contents are a complete core WebAssembly module, preamble included, unchanged by the component model. It is described on the core module pages. It adds one entry to the core module index space; nothing runs until a core instance is made from it.
Core instance (2)
A vector of core instance definitions. Instances associate code with state; this is what makes a core module run.
| Form | Encoding | Meaning |
|---|---|---|
00 | moduleidx, vec(core:instantiatearg) | instantiate: create an instance of core module moduleidx. |
01 | vec(core:inlineexport) | An instance made directly by tupling existing definitions, without a module. |
| Item | Encoding | Meaning |
|---|---|---|
| core:instantiatearg | name, 12, instanceidx | (with name (instance i)): supplies the core instance i for the module’s imports whose first name is name. The byte 12 is the instance core:sort. |
| core:inlineexport | name, core:sortidx | (export name sortidx). |
When a core module is instantiated, the first of its two import names selects a
with argument and the second selects one of that instance’s exports.
Validation of core:instantiatearg initially allows only the instance sort and
would be widened as core WebAssembly is extended.
Core type (3)
A vector of core type definitions: ordinary core types, plus core module types. They are described on the types page.
Component (4)
The contents are a whole nested component, preamble included. It adds one entry to the
component index space. A nested component is code, not an instance: it needs an
instance definition to run. Components have their own index spaces, so
nested sections start with empty spaces and can reach outwards only through outer aliases.
Instance (5)
A vector of component instance definitions, symmetric to core instances.
| Form | Encoding | Meaning |
|---|---|---|
00 | componentidx, vec(instantiatearg) | instantiate component componentidx. |
01 | vec(inlineexport) | An instance made by tupling existing definitions. |
| Item | Encoding | Meaning |
|---|---|---|
| instantiatearg | name, sortidx | (with name sortidx): supplies a definition for the import called name. |
| inlineexport | nameattributes, sortidx | (export na sortidx); the nameattributes encoding is on the names page. |
Validation of instantiate requires each externname in the
component’s imports to match a name in a with argument (plain
string equality) and the types to match. When validating, as each type import is
supplied, the actual type is immediately substituted for every use of the import, so that
later imports and all exports are specialised to it.
Alias (6)
An alias projects a definition from another index space into the current one. Each alias starts with a sort (the sort of the thing aliased), then a kind byte.
| Kind | Encoding after the sort | Meaning |
|---|---|---|
00 | instanceidx, name | (alias export i n (s)): export n of component instance i. i must name an instance that exports n with that sort. |
01 | core:instanceidx, core:name | (alias core export i n (s)): export n of core instance i. |
02 | u32 count, u32 index | (alias outer ct idx (s)): a definition of an enclosing scope. Only when s is one of the outer-alias sorts: core module, core type, component or type. |
For outer aliases ct must be at most the number of enclosing
scopes, where a scope is a component definition, a component type or an instance type;
0 is the current scope, and idx must be valid in the target scope’s index
space for the sort. If ct is above 0, crosses a component (not just type)
boundary and the sort is type, the type may not transitively refer to a resource type,
because resource types are generative. Inside a component or instance type,
aliases are further restricted: export aliases may only alias the instance
and type sorts, and outer aliases only the core type and type sorts.
Type (7)
A vector of component type definitions: value types, function types, resource types, component types and instance types. See the types page.
Canon (8)
A vector of canonical definitions: lift, lower and the
built-ins. See the canonical definitions
page. lift adds a component function; lower and the built-ins add
core functions.
Start (9) – 🪙
The component-level start function, called while the component is instantiated. Unlike a module start, a component can have several, each with arguments and results. This section is gated (🪙).
| Field | Encoding | Meaning |
|---|---|---|
| f | funcidx | The function to call. |
| arg* | vec(valueidx) | Arguments, from the value index space. |
| r | u32 | Number of results. |
Validation requires f to have a function type whose parameter count and types match the arguments and whose result count is r. The results are appended to the value index space.
Import (10)
| Field | Encoding | Meaning |
|---|---|---|
| name | nameattributes | The import’s single name, plus attributes. |
| type | externtype | What is imported: core module, function, value 🪙, type, component or instance. |
A component import has one name, not two as in core modules; a two-level import is made
by importing an instance. Components may import and export every component sort but, of
the core sorts, only module. This keeps all calls between components going
through a lift and lower. The import’s sort is that of its type, and each import adds an
entry to that sort’s index space. All import names in one component or component type
must be strongly unique; attributes are ignored (see
names).
Export (11)
| Field | Encoding | Meaning |
|---|---|---|
| name | nameattributes | The export’s name and attributes. |
| definition | sortidx | The exported definition, which must precede the export. |
| type | optional externtype: 00 for none, or 01 then an externtype | An optional ascribed type that replaces the inferred one. |
Every export, whatever its sort, also adds a new index that aliases the exported
definition and can be used by later definitions. Validation rules from Binary.md:
- Every resource type used (transitively) in the type of an export must have been introduced by a preceding import or export declaration (“external visibility”). The same applies to
record,variant,enumandflagstypes, so that source languages have a name for them. Imported types cannot refer to the external names of exported types. - The exported sortidx must have a valid externtype, which excludes core sorts other than module. If an externtype is ascribed it must be a supertype of the inferred one.
- A
borrowmay not appear transitively in an exported value type. - Export names in a component, instance, component type or instance type must be strongly unique.
Value (12) – 🪙
A value definition is an immutable constant in the value index space, like a global. Validation requires every value to be consumed exactly once, by an export, an instantiation argument or a start argument. Each value has a “consumed” flag, clear when it is added by an import, instance, alias or start; set when used; and after the last definition of a component all flags must be set. The section is gated (🪙).
| Field | Encoding |
|---|---|
| type | valtype |
| len | u32: the size in bytes of the value that follows |
| value | the bytes of val(type), below |
| Type | Encoding of the value |
|---|---|
| bool | 00 false, 01 true |
| u8 | one byte |
| s8 | one byte, read as two’s complement (128 to 255 mean −128 to −1) |
| s16, u16, s32, u32, s64, u64 | the core LEB128 integer encoding of that type |
| f32, f64 | the core float encoding. NaN is written as one canonical pattern only: 00 00 C0 7F (f32) or 00 00 00 00 00 00 F8 7F (f64); a non-canonical NaN is not accepted. |
| char | the UTF-8 bytes of one Unicode scalar value, to the end of the value |
| string | a core name: u32 length, then UTF-8 |
| a type index | the encoding of the type that index names |
| record | the field values in order |
| variant | the case index (u32), then the payload if that case has one |
| list | vec of the element values (u32 count, then the elements) |
| list with length 🔧 | exactly len element values, no count |
| tuple | the element values in order |
| flags | ceil(n / 8) bytes; label i is set if bit i mod 8 of byte floor(i / 8) is 1 |
| enum | the case index, u32 |
| option | 00 for none, 01 then the value for some |
| result | 00 for ok, followed by the ok value when the ok type exists; 01 for error, followed by the error value when the error type exists |
| map 🗺️ | vec of entries; each entry is the key value then the value |
A valtype may only be used for a value if every type constructor in it has
a value encoding. The text format excludes own, borrow,
future, stream and error-context, so
(option (stream u8)) is rejected. An integer value must fit its type’s range.
Example
A component with one function type func () -> u32, one import of a function
of that type called f, and one export of it called g. The bytes
were worked out from the grammar above, not produced by a tool or run through a
validator:
00 61 73 6D 0D 00 01 00 preamble: magic, version 0x0d, layer 1
07 05 01 40 00 00 79 type section: 1 type; 40 = func, 00 = no params,
00 79 = one result, u32
0A 06 01 00 01 66 01 00 import section: 1 import; nameattributes 00 01 'f';
externtype 01 = func, type index 0
0B 07 01 00 01 67 01 00 00 export section: 1 export; name 00 01 'g'; sortidx
01 00 = func 0; 00 = no ascribed type
Sources
design/mvp/Binary.md (sections “Component Definitions”, “Instance Definitions”,
“Alias Definitions”, “Start Definitions”, “Import and Export Definitions”, “Value
Definitions”) and design/mvp/Text.md (“Index Spaces”, “Component Definitions”,
“Alias Definitions”, “Import and Export Definitions”, “Value Definitions”, “Start
Definitions”, “External Visibility of Types”) in
github.com/WebAssembly/component-model,
raw files read 2026-11-18. The example bytes are worked out from the grammar.