CoderTools

Matter Protocol Codec

Decode and encode Matter TLV data for smart home development

🔒 100% Local ProcessingYour input data is processed entirely in your browser. It is not uploaded to any server.

Paste TLV data captured from Matter devices or protocol analyzers

Click to Load Example

Decoded Result

Enter TLV data and click Decode to see results

TLV Element Types

Type Name Type Code Value Size
Signed Int0x00-0x031, 2, 4, 8 bytes
Unsigned Int0x04-0x071, 2, 4, 8 bytes
Boolean0x08-0x090 bytes
Float0x0A4 bytes
Double0x0B8 bytes
UTF-8 String0x0C-0x0F1/2/4/8-byte length + data
Byte String0x10-0x131/2/4/8-byte length + data
Null0x140 bytes
Structure0x15End-of-Container (0x18)
Array0x16End-of-Container (0x18)
List0x17End-of-Container (0x18)
End of Container0x180 bytes

Matter Protocol Technical Reference

C Struct Schema Usage Guide

The C Struct Schema mode allows you to define data structures using familiar C/C++ syntax. The parser extracts field names, types, and TLV tags from your struct definitions, then generates a visual form for easy data entry and TLV encoding.

Supported Syntax

// Supported syntax forms:
typedef struct { ... } StructName;
typedef struct Tag { ... } StructName;
struct StructName { ... };

Supported Data Types

Category C/C++ Types TLV Type
Signed Integer int8_t, int16_t, int32_t, int64_t, char, short, int, long int (1-8B)
Unsigned Integer uint8_t, uint16_t, uint32_t, uint64_t, unsigned char/short/int/long, size_t uint (1-8B)
Boolean bool, _Bool bool
Floating Point float, double float/double
String char[], char[N], char* UTF-8 string
Byte Array uint8_t[], uint8_t[N], uint8_t* byte string

Tag Annotation Methods

Use comments to specify TLV context tags for each field. If no tag is specified, tags are auto-assigned starting from 0.

uint8_t field1;     // tag 0
uint16_t field2;    // tag: 1
uint32_t field3;    /* tag 2 */
@tag(3) uint64_t field4;

Array Support

Fixed-size arrays (e.g., uint32_t data[4]) and variable-size arrays (e.g., uint8_t data[]) are supported. The form will provide an "Add Item" button for dynamic array element management.

uint32_t subjects[4];  // Fixed-size array (max 4 items)
uint8_t data[];        // Variable-size array

Current Limitations

  • Preprocessor directives (#define, #ifdef) are not supported
  • typedef aliases (e.g., typedef uint8_t BYTE) are not supported
  • Enums, unions, and bit-fields are not supported
  • Nested struct editing is limited to one level
  • Anonymous structs are not supported

What is Matter

Matter is a unified connectivity standard for smart home devices, originally developed under the name Project CHIP (Connected Home over IP) by the Connectivity Standards Alliance (CSA). The standard enables interoperability across ecosystems such as Apple HomeKit, Google Home, Amazon Alexa, and Samsung SmartThings. Devices compliant with Matter communicate over Wi-Fi, Thread, and Ethernet networks, using IPv6-based transport protocols. Matter 1.0 was released in October 2022, and subsequent revisions have expanded the range of supported device types.

Matter TLV Encoding Format

Matter uses a compact Tag-Length-Value (TLV) binary encoding scheme to serialize structured data. The format is used extensively across the protocol stack, including in Interaction Model messages, device attestation data, and commissioning payloads. Each TLV element consists of a control byte that encodes both the element type and tag form, followed by tag bytes (if any), length (for variable-length types), and the value payload.

Control Byte Structure

The control byte is the first byte of every TLV element. The lower 5 bits specify the element type, and the upper 3 bits indicate the tag form. This compact encoding allows single-byte representation for small values and tags.

Bit Field Description
Bits [4:0]Element type (Signed/Unsigned Integer, Boolean, Float, UTF-8 String, Byte String, Null, Structure, Array, List, End of Container)
Bits [7:5]Tag form: 000 = Anonymous, 001 = Context-specific (1-byte tag), 010-110 = Profile-specific tags, 111 = Fully Qualified

TLV Element Types

The element type field determines how the value portion is encoded. Integer types use 1, 2, 4, or 8 bytes. Boolean values are encoded directly in the type field with no value bytes. Strings and byte arrays carry a length prefix followed by the data.

Onboarding Payload Format

When commissioning a new Matter device, the setup information is encoded in a compact payload embedded within a QR code or expressed as a numeric manual pairing code. The QR code payload begins with the prefix "MT:" followed by a Base38 encoded binary string containing the version, vendor ID, product ID, commissioning flow, discovery capabilities, discriminator, and setup passcode.

Base38 Encoding

Matter QR code payloads use a Base38 character set (0-9, A-Z, -.) for efficient alphanumeric representation. This encoding was chosen to fit within the constraints of QR code alphanumeric mode while maximizing data density. Every group of 3 bytes is encoded into 5 Base38 characters.

Manual Pairing Code

The 11-digit manual pairing code provides a fallback commissioning method when QR code scanning is unavailable. It encodes the discriminator (short form), setup passcode, and a Verhoeff check digit. The 21-digit version additionally includes the vendor ID and product ID for custom commissioning flows.

Verhoeff Check Digit

The manual pairing code uses the Verhoeff algorithm for error detection. This algorithm detects all single-digit errors and most adjacent transposition errors, making it well-suited for human-entered numeric codes.

Development Use Cases

  • Debugging Matter TLV payloads captured from device interactions
  • Inspecting Interaction Model request and response messages
  • Verifying commissioning payloads embedded in QR codes
  • Validating device attestation certificate TLV structures
  • Building test payloads for Matter protocol conformance testing

Specification References

The Matter specification is maintained by the Connectivity Standards Alliance (CSA). The TLV encoding format is defined in the Core Specification Appendix A. Onboarding payload encoding is covered in Section 5.1.

Quick Menu

No recent tools