Home > Tools > BER-TLV Parser

BER-TLV Parser

Parse hex TLV (Tag-Length-Value) data from EMV, GlobalPlatform, and ISO 7816 smart card protocols. Supports 1-2 byte tags, multi-byte lengths (0x81-0x84), and nested constructed TLV structures.

Presets:
Enter hex TLV data and click Parse.

Supports: ISO 7816-4 BER-TLV, EMV Book 3, and GlobalPlatform encoding rules. Tag can be 1 byte (e.g. 5A) or 2 bytes when bits 5-1 of the first byte are 11111. Length uses short form (1 byte, <0x80) or long form (0x81-0x84 prefix followed by 1-4 length bytes).

How to Use

Input: Paste a hex string (with or without spaces) containing BER-TLV encoded data. This commonly comes from EMV card responses (SELECT response, GPO response, READ RECORD), NFC tags, or GlobalPlatform commands.

Output: Each TLV is shown with its tag, length, and value. Constructed tags (those containing nested TLVs) show their children indented. Tag names are auto-resolved from the EMV tag database when available.

Example Use Cases

BER-TLV Encoding Rules

BER-TLV (Basic Encoding Rules, Tag-Length-Value) is the fundamental encoding used in smart card communications, defined in ISO/IEC 8822. EMV, GlobalPlatform, and ISO 7816-4 all use TLV encoding for data exchange. Understanding TLV is essential for debugging APDU responses and card data.

Tag Encoding

Tag is 1 or 2 bytes. The first byte's bits: bit 8-7 (class: 00=universal, 01=application, 10=context-specific, 11=private), bit 6 (constructed flag: 1=contains nested TLV, 0=primitive), bits 5-1 (tag number). If bits 5-1 are all 1s (0x1F), the tag continues in the next byte. Multi-byte tags use the continuation pattern where subsequent bytes have bit 8 set. The constructed flag (bit 6) tells the parser whether to attempt recursive decoding of the value field.

Length Encoding

Length is 1-5 bytes. Short form: if the first byte is 0x00-0x7F (0-127), it directly represents the length. Long form: if the first byte is 0x81-0x84, the low nibble indicates how many following bytes encode the length (1-4 bytes, big-endian). For example, 0x820100 means 256 bytes. Indefinite form (0x80) is not used in DER but may appear in BER. This parser handles short and long forms, and attempts recursive decoding of constructed tags, falling back to displaying the raw hex value if recursive parsing fails.