Skip to Content
DocsLanguageVein Wire Format

Vein Wire Format

Vein is LODE’s compact binary encoding. Every compiled LODE object is a Vein payload.

Binary Layout

OffsetSizeFieldDescription
01Magic[0]0x4C ('L')
11Magic[1]0x44 ('D')
21VersionSchema version (matches schema.version)
31CountNumber of encoded fields

The magic bytes LD identify the payload as a Vein binary. Any file or buffer starting with 0x4C44 is a candidate Vein payload.

Field Entry

Each field is encoded as:

OffsetSizeFieldDescription
01Field IDNumeric field identifier (1–255)
11Type TagWire type (see Type System)
22LengthData length in bytes (big-endian uint16)
4NDataType-specific encoded value

The maximum data length per field is 65,535 bytes (2^16 - 1).

Content Type

Vein binaries are served with the MIME type:

Content-Type: application/x-vein

Byte Order

All multi-byte integers in Vein are big-endian (network byte order). This includes:

  • Field data length (2 bytes)
  • String array item count (2 bytes)
  • String array item lengths (2 bytes each)
  • Map entry count (2 bytes)
  • Map key/value lengths (2 bytes each)

Size Characteristics

For a typical model layer with 5 fields:

FormatSize
JSON (pretty)~350 bytes
JSON (compact)~220 bytes
Vein~90 bytes

The Vein encoding is roughly 60% smaller than compact JSON for structured data with string fields.

Last updated on