SBE: reading the XML message schema
Learn how an SBE XML message schema declares byte order, reusable types, presence and null rules, messages and schema versions—and how each XML element maps to wire bytes.
Simple Binary Encoding (SBE) is the FIX Trading Community's binary wire format used by exchanges and trading systems for low-latency market data and order entry (how an SBE message is laid out). Because SBE wire bytes carry no field names or tags, every decoder—generated or dynamic—starts from the venue's XML message schema.
Reading that XML file tells you the byte order, message header, type encodings, null rules, field order, and version history. This page maps each XML element to what actually appears on the wire, using Binance's bundled Spot Streams (binance_stream_1_0_sbe.xml) and Spot API (binance_spot_3_6_sbe.xml) schemas.
A schema at a glance
Open the bundled Binance Spot Streams schema in the Market Data Visualizer to compare its root attributes and the TradesStreamEvent declaration below with the XML elements described here.
Open the Binance streams schema attributes in the Market Data Visualizer
TradesStreamEvent :: message @10000 {
eventTime: utcTimestampUs :: type int64; // UTC timestamp in microsecondsutcTimestampUs; @1
transactTime: utcTimestampUs :: type int64; // UTC timestamp in microsecondsutcTimestampUs; @2
priceExponent: exponent8 :: type int8; // Exponent for a decimal floating point number.exponent8; @3
qtyExponent: exponent8 :: type int8; // Exponent for a decimal floating point number.exponent8; @4
trades: group @100 {
id: tradeId :: type int64;tradeId; @1
price: mantissa64 :: type int64; // 64-bit mantissa for a decimal floating point number. The name of the field containing the exponent value is specified in the mbx:exponent attribute of the mantissa64 field. The exponent field will always precede the mantissa field.mantissa64; @2
qty: mantissa64 :: type int64; // 64-bit mantissa for a decimal floating point number. The name of the field containing the exponent value is specified in the mbx:exponent attribute of the mantissa64 field. The exponent field will always precede the mantissa field.mantissa64; @3
isBuyerMaker: boolEnum :: enum uint8 // 1 BboolEnum; @4
isBestMatch: boolEnum :: enum uint8 // 1 BboolEnum const = boolEnum.True; @5
}
symbol: data varString8 :: composite // Variable length UTF-8 string.varString8; @200
}The schema element
The root <messageSchema> element sets protocol-wide properties:
package: namespace/package name for generated code (spot_streamhere;spot_sbein Spot API).id: numeric schema id carried in every header'sschemaId(1for streams,3for Spot API).version: schema version carried in every header'sversion(0for streams,6for Spot API 3.6).byteOrder:littleEndian(default) orbigEndian(endianness).headerType: composite used as the message header (defaults tomessageHeader).
Schemas can split shared types into separate files using XInclude (xi:include). Open included files in the same project alongside the root schema or the app reports IncludeNotProvided.
Types
<types> defines every reusable type in four forms:
Simple types
<type> wraps an SBE primitive (char, int8–int64, uint8–uint64, float, double) with optional attributes: length (fixed array), minValue / maxValue, nullValue (presence and null values), and presence="constant" (schema-only, 0 wire bytes). In Binance's schemas, mantissa64 wraps int64:
Composites
<composite> packs multiple members back to back into one inline type—used for decimal prices (precision, scale and exponent), repeating-group dimension headers (groupSizeEncoding, see variable-sized data and lists), variable-length data headers (varString8, messageData), and messageHeader:
Enums
<enum> maps named values to a char or unsigned integer encodingType. In Binance's schemas, boolEnum encodes 2 values (False, True) as uint8:
Sets
<set> defines a bit field over an unsigned integer, where each <choice> names a bit position and multiple choices may be active together. In the Spot API schema, orderTypes packs 8 choices into a uint16 with Market at bit 0:
Messages
Each <message> has a unique id (sent as templateId in the header) and declares its members in strict wire order:
<field>: fixed-size root-block fields (how an SBE message is laid out).<group>: repeating groups (variable-sized data and lists), each with its own fields, nested groups, and data.<data>: variable-length data fields.
A <field> requires name, id, and type. Its id is its FIX tag number—never written on the wire, and it does not determine byte order or offset. Offsets follow XML declaration order unless a field explicitly sets offset.
Presence and null values
Every SBE field or type declares a presence attribute:
required(default): always carries a valid value, never a null value.optional: may be empty, which a reserved null value says while the field still takes its full byte width (null values).constant: fixed in the schema (often referencing an enum value viavalueRef, likeisBestMatchinTradesStreamEvent/trades); takes zero bytes on the wire.
When an optional type declares no nullValue, SBE reserves one end of its primitive's range: the minimum for signed integers (−128 for int8, −2^31 for int32, −2^63 for int64), the maximum for unsigned integers (255 for uint8, 65535 for uint16, 2^32 − 1 for uint32), 0 for char, a quiet NaN for float and double, and a mantissa of −2^63 for a 64-bit decimal. Any type can set its own with nullValue (B3 Binary UMDF sets nullValue="0" on several integer types), so a decoder reads each type's null value from the schema instead of assuming the defaults. In the Binance Spot API sample, orderListId in NewOrderAckResponse is optional:
Versions and sinceVersion
Backward-compatible schema updates append new fields, groups, or data after existing ones and tag each addition with sinceVersion (and retired items with deprecated, keeping them on the wire during migration). While binance_stream_1_0_sbe.xml is at version 0, binance_spot_3_6_sbe.xml is at version 6 and uses sinceVersion extensively—such as subscriptionId (sinceVersion="1") on BalanceUpdateEvent. See schema versioning for how decoders handle version mismatches using version and blockLength.
Open subscriptionId and its sinceVersion in the Market Data Visualizer
What to check when reading a schema
- Check
<messageSchema>first forbyteOrder,headerType,id, andversion, plus anyxi:includefiles you must load alongside it. - Ignore field
idnumbers when computing offsets; only XML order, explicitoffset, andpresence="constant"affect wire positions. - Inspect each type's
nullValueandpresencerather than relying on SBE defaults.
Sources
- https://www.fixtrading.org/what-is-the-fix-protocol/
- https://www.fixtrading.org/standards/sbe/
- https://github.com/FIXTradingCommunity/fix-simple-binary-encoding
- https://github.com/FIXTradingCommunity/fix-simple-binary-encoding/blob/master/v1-0-STANDARD/doc/04MessageSchema.md
- https://github.com/FIXTradingCommunity/fix-simple-binary-encoding/blob/master/v1-0-STANDARD/doc/05SchemaExtensionMechanism.md
- https://github.com/real-logic/simple-binary-encoding/wiki/FIX-SBE-XML-Primer
Reviewed by Structure on 2026-11-24. Last changed 2026-11-23.