EMV TLV Parser
Decode BER-TLV data from EMV chip transactions into tag, length and value, with names resolved from a dictionary of more than a hundred published EMV tags. You can also build a TLV string from tag and value pairs.
A worked example: 6F1A840E315041592F5359532E4449414C4C5920 decodes to a File Control Information template containing a record template with the application label "SYSTEM.DIALLPAY".
How this tool works
An EMV record is a sequence of tag, length and value triples, and the encoding is defined in the EMVCo specifications. The tag says what the data is, the length says how many bytes the value occupies, and the value is the data. Parsing is a matter of reading those three parts in order and repeating until the record is exhausted.
The complication is BER-TLV, where the length field is itself variable. A length byte with its top bit set means the length continues in the following byte, and there is a nested form where a length of 0x80 signals a constructed tag whose value is a further sequence of triples. A parser that only handles single-byte lengths will fall over on the first constructed tag it meets.
A parsed tag list
| Tag | Name | Length |
|---|---|---|
| 6F | File Control Template | constructed |
| 84 | Dedicated File Name | 16 |
| A5 | FCI Proprietary Template | constructed |
| 50 | Application Label | 12 |
| 57 | Track 2 Equivalent Data | 19 |
| 5A | Application PAN | 10 |
A constructed tag has no value of its own. Its value is the sequence of triples that follows, and the parser descends into it.
When to use it
- Read a chip transaction record field by field
- Debug a terminal or a card reader that is producing unexpected values
- Find which tag in a record is malformed
- Understand the structure of a chip application record
Frequently asked questions
What is TLV in EMV?
Tag, length, value: the encoding used for the data elements in a chip record. The tag identifies the data, the length gives the size of the value, and the value is the data itself.
What is BER-TLV?
The variable-length form of the encoding, defined in the EMVCo specifications. A length byte with the top bit set means the length continues in the next byte, and a length of 0x80 marks a constructed tag whose value is a nested sequence of triples.
What are the constructed tags?
Tags whose value is itself a sequence of triples, such as the File Control Template and the FCI Proprietary Template. A parser has to descend into them rather than reading them as opaque data.
Do I need an EMV terminal to use this?
No. The parsing is arithmetic over a byte string, and a record captured from a terminal can be decoded here afterwards.
What is the application label?
A short human-readable name for the card application, typically the scheme or the issuer's brand, carried in tag 50. It is the quickest way to see what a record says it is.
Is a parsed record valid?
It is well formed. Whether the record is genuine, whether the application was accepted and whether the transaction was approved are separate questions, and a captured record can be a declined one.