BER-TLV decoder
Almost all EMV data is encoded as BER-TLV: a tag that says what the data is, a length in bytes, and the value. The card returns it in its responses to the terminal (APDU responses), and the terminal sends it to the issuer in DE 55 of the authorization message.
Paste data here when you need to see what a card returned or what a terminal sent: a GET PROCESSING OPTIONS response, a card record, or the DE 55 field from a host log.
The result is a tree. Each row shows the tag, its name from the dictionary, the length, and the value, and constructed tags (templates) hold their children. The decoder keeps going when it finds bytes it cannot read and marks them; strict mode stops at the first error. The PAN and track data are masked by default and never go into a share link.
Worked example: the GPO response example, 77 12 82 02 1980 94 0C 08010100 10010301 18010201, is template 77 with 18 bytes inside. It holds tag 82, the application interchange profile (AIP) 1980, and tag 94, the application file locator (AFL), whose three 4-byte entries list the records to read.
New to EMV? Read EMV in 5 minutes or browse the glossary
Everything runs in your browser. Nothing you enter leaves this page.
Anatomy of a TLV object
- Bits 8 and 7 give the class. Here they are 10: a context-specific tag, the class of most EMV tags.
- Bit 6 says whether the object is primitive (0) or constructed (1). Here it is 0: the value is plain data.
- Bits 5 to 1 hold the tag number. When they are all 1 (11111), as here, the number continues in the next byte.
Other cases
- Two-byte tags: the first byte ends in 11111, so the tag continues, as in 9F02. If bit 8 of the next byte is 1, a third tag byte follows.
- Long lengths: a length byte from 00 to 7F is the length itself. 81 means the next byte holds the length, up to 255 bytes, and 82 means the next two bytes hold it, up to 65,535 bytes.
- Constructed objects: when bit 6 of the first tag byte is 1, the value holds more TLV objects instead of data, as in 70 (a record template) and 77 (the GET PROCESSING OPTIONS response).