Glossary · Data

UA Binary encoding

In OPC UA, UA Binary is the default wire encoding: a compact, little-endian, unpadded serialisation of every service message and data type. It is what opc.tcp carries, and what the https-uabinary and wss-uasc-uabinary transport profiles carry inside HTTP bodies and WebSocket binary frames.

The encoding rules that matter

Integers are little-endian and fixed width with no alignment padding. Strings and ByteStrings are an Int32 byte length followed by UTF-8 or raw bytes, with a length of minus one meaning null, which is distinct from a length of zero meaning empty. Arrays are an Int32 element count followed by the elements, again with minus one for null. DateTime is a 64-bit count of 100-nanosecond intervals since 1601-01-01 UTC. Optional fields, as in DataValue, are governed by a leading encoding mask.

Chunking and limits

Messages larger than the negotiated chunk size are split into MessageChunks over the secure channel and reassembled. The negotiated MaxMessageSize and MaxChunkCount are what produce BadTcpMessageTooLarge, BadEncodingLimitsExceeded, BadRequestTooLarge and BadResponseTooLarge. These limits are the usual reason a Browse or HistoryRead that works on a small server fails on a large one, and the fix is paging with continuation points rather than raising limits indefinitely.

Binary versus JSON in practice

UA Binary is the smallest and fastest of the client-server encodings and is fully type-preserving, so it is the right default for everything except browser and REST-style access. The JSON and OpenAPI transport profiles do not negotiate a UA secure channel at all: they are advertised with MessageSecurityMode None and rely entirely on TLS. If you switch away from binary for convenience, you have changed your security architecture too, not just your serialisation.

Structures and DataTypeDefinition

Server-defined structures travel as ExtensionObjects: a type identifier plus a binary body. A client decodes them either from the DataTypeDefinition attribute on the DataType node, which is the 1.04 and later mechanism, or from a legacy binary type dictionary. A mismatch between what the server publishes and what your client supports is what leaves you holding an undecoded ExtensionObject rather than a typed value.

Example

How an OPC UA String is laid out in UA Binary

String "OK"     : 02 00 00 00 4F 4B        # Int32 length = 2, then UTF-8 bytes
String ""       : 00 00 00 00              # length 0, empty string
String null     : FF FF FF FF              # length -1, null (not the same as empty)
Int32 42        : 2A 00 00 00              # little-endian, no padding
Boolean true    : 01
The mistake people make: Treating a null and an empty string or array as the same thing. UA Binary distinguishes minus one from zero, and a server that expects a null optional field can reject an empty one with BadDecodingError or, worse, interpret it as a deliberate blank value.

Defined in: Part 6 - Mappings, UA Binary encoding.

Last verified 7 September 2026 against OPC UA 1.05.07. OPC UA Connect is an educational resource and is not affiliated with the OPC Foundation.

Free download
OPC UA Server Acceptance Test Pack
A 40-check acceptance test you run against a vendor's server before commissioning sign-off. Weighted scoring, three hard gates, and a one-page verdict for the supplier meeting.
Get the free test pack →
Free, no course, no login