Schema Guide
Define binary layouts with a compact, file-focused DSL.
Hex Master schemas describe endianness, named structs, scalar fields, byte ranges, arrays, repeat blocks, and offset-based sections. Run a schema at a chosen base offset to parse a file region into a structured tree with offsets, sizes, coverage reporting, and JSON export.
Quick Start
What a schema contains
Required parts
- One endianness line:
endian littleorendian big - Zero or more named
structblocks - Exactly one
rootblock
Run behavior
- The base offset is chosen when you run the schema
- Fields parse in order
- Later fields can refer to earlier scalar fields in the same scope
- Repeat blocks can iterate arrays parsed earlier in the file
endian littlestruct Entry {u32 idu16 flagsu16 value}root Header {bytes[4] magicu16 versionu16 entry_countEntry[entry_count] entries}
Grammar
Core forms
Scalars
u8,u16,u32,u64i8,i16,i32,i64f32,f64
Byte ranges
bytes[16] header- Useful for magic values, opaque blocks, or raw payload slices
Struct fields
Header headerEntry[count] entries
u32 count
Read one 32-bit unsigned integer
bytes[32] blob
Read 32 raw bytes
Entry[count] entries
Read an array of structs using an earlier scalar count
Entry[count] entries @table_offset
Read an array from a different location in the file
Entry[count * 2] entries @base + 0x20
Use expressions in both count and offset
repeat subHeader in meshHeader.subHeaders { ... }
Iterate a previously parsed array to drive a later staged section
Expressions
Supported in counts and offsets
Supported
- Earlier scalar fields in the same scope
- Decimal integers
- Hex integers like
0x20 +,-,*,/- Parentheses
- Dotted references inside repeat scopes like
subHeader.faceCount
Examples
Entry[count + 1] entriesbytes[numBones * 48] pose_dataSection[sectionCount] sections @headerSize + 0x20
Repeat Blocks
Use staged parsing when headers describe later sections.
Form
repeat alias in sourcePath { ... }- The source must resolve to an earlier parsed array
- The block parses sequentially at the current file position
Inside the block
aliasrefers to the current repeated item- Dotted references like
meshHeader.subHeadersare supported - Counts and offsets can use values such as
subHeader.vertexCount
Interaction
Using the structure tree
What it shows
- Parsed field names and types
- Offsets and sizes for each parsed region
- Interpreted scalar and byte values
How to use it
- Click a field to select that byte range in the main hex view
- Use the tree to inspect parsed structure layout
- Use the main hex editor itself for byte-level modifications
- Export the current parsed tree to JSON from the Schema Editor file menu
Examples
Offset-based table
endian littlestruct Entry {u32 idu16 flagsu16 value}root Header {bytes[4] magicu16 versionu16 entry_countu32 entries_offsetEntry[entry_count] entries @entries_offset}
Here, entry_count controls the number of items, and
entries_offset points to where the array begins relative to the selected base offset.
Examples
Character animation block with dependent transform count
endian littlestruct Transform {f32 r00f32 r01f32 r02f32 r10f32 r11f32 r12f32 r20f32 r21f32 r22f32 pxf32 pyf32 pz}struct Action {u16 numBonesu16 numFramesTransform[numBones * numFrames] transforms}struct Actor {u16 numActionAction[numAction] actions}root CharAni {u32 numActorsActor[numActors] actors}
This pattern is useful for animation formats where the payload count depends on more than one earlier field.
Examples
Staged mesh layout with repeat blocks
endian littlestruct SubHeader {i32 faceCounti32 vertexCount}struct MeshHeader {i32 subMeshCountSubHeader[subMeshCount] subHeaders}struct Face {u16 au16 bu16 c}root ItemObj {i32 numMeshesMeshHeader[numMeshes] headersrepeat meshHeader in headers {repeat subHeader in meshHeader.subHeaders {Face[subHeader.faceCount] facesf32[subHeader.vertexCount] posXf32[subHeader.vertexCount] posYf32[subHeader.vertexCount] posZ}}}
This pattern is useful for formats where headers are grouped first, but the payloads they describe
appear later in the file. A fuller sample is available in docs/examples/item_obj.schema.
Limits
What the current DSL does not support yet
Not supported
- Conditional fields
- Unions
- Arbitrary random-access pointer chasing beyond supported offset expressions and repeat scopes
- Named enums or bitfields
Authoring rule
- Define dependent fields after the scalar values they depend on
- Use repeat blocks when a later section depends on an earlier parsed array