Understanding Data Types in ISO 8583

ASSI Avatar

Back when I was working on a host emulator project for issuer and acquirer simulations, one of the tricky areas I faced early on was understanding how the data elements in ISO 8583 are formatted. It wasn’t just about packing and unpacking the messages, the real challenge was knowing how to interpret the field types like n, an, b, or LLVAR.

If you’re starting with ISO 8583 or even building something like a custom payment switch, this guide should save you from many hours of confusion.

What Are Data Types in ISO 8583?

ISO 8583 defines how transaction messages are structured for payment systems, everything from ATMs to POS terminals. Each field or “data element” in the message has a data type that tells you two things:

  1. What kind of characters it contains (e.g., digits, letters, symbols)
  2. How it should be encoded (e.g., ASCII, BCD, binary)

In total, the standard supports a variety of data types, each serving a purpose based on the type of data being transmitted.

Common Data Types and Their Meanings

Here’s a table I use for quick reference:

CodeMeaningCharacter SetCommon Encoding
nNumeric0 – 9BCD / ASCII
aAlphabeticA – ZASCII
anAlphanumericA – Z, 0 – 9ASCII
ansAlphanumeric + symbolsA – Z, 0 – 9, symbolsASCII
bBinaryRaw bytesBinary
zCompressed numericDigitsBCD

Let’s break each of these down with examples.


n – Numeric

Used when the field contains only digits. It’s commonly BCD-encoded, which means two digits are packed into each byte.

Example:

C#
// PAN (Primary Account Number)
string pan = "12345678";
// In BCD: 0x12 0x34 0x56 0x78

Typical Fields:

  • Field 2: PAN
  • Field 4: Transaction Amount

a – Alphabetic

Contains only letters. Not very common except for specific codes or names.

Example:

C#
string merchantCategoryCode = "FOOD"; // ASCII encoding

an – Alphanumeric

Used when the field can have both letters and digits.

Example:

C#
string terminalId = "ATM1234"; // ASCII: 41 54 4D 31 32 33 34

Type Fields:

  • Field 41: Terminal ID
  • Field 42: Card Acceptor ID Code

ans – Alphanumeric and Special Characters

This is more flexible than an. You might see this for free text, discretionary data, or track data.

Example:

C#
string trackData = "1234ABCD=9876?"; // ASCII string with special characters

Note: Used often for Field 35 or Field 45 (Track 2 / Track 1 data)

b – Binary

This one threw me off the first time I had to handle MAC or EMV data. The data isn’t meant to be human-readable, it’s raw bytes.

Example:

C#
byte[] mac = new byte[] { 0xDE, 0xAD, 0xBE, 0xEF }; // Field 64 or 128

Encoding Tip: Don’t convert binary fields to hex strings unless explicitly needed.

z – Compressed Numeric

This is an older format, a variant of BCD. It’s not widely used in modern implementations, but you might see it in legacy systems.

Variable Length: LLVAR and LLLVAR

While not data types per se, many fields use length prefixes:

  • LLVAR: 2-digit length (up to 99 characters)
  • LLLVAR: 3-digit length (up to 999 characters)

These prefixes tell how long the actual value is.

Example:

Plaintext
Field 44: LLVAR (response message text)
Value: "DECLINED"
Encoded as: 08 4445434C494E4544 (08 = length, rest = ASCII)

Real World Tip: Check the Spec Sheet

ISO 8583 isn’t a single fixed format. Different networks (like Visa, MasterCard, AMEX, or a local switch) customize their message specifications. Always work with the actual field guide provided by your acquiring partner or payment network.

Final Thoughts

Understanding ISO 8583 data types isn’t just about compliance, it’s about getting your system to communicate properly in the payments world. I’ve personally debugged dozens of malformed messages that traced back to simple type mismatches, using an instead of n, forgetting to apply BCD encoding, or miscalculating LLVAR lengths.

If you’re building tools like host simulators, EMV validators, or even just integrating with a switch, take time to get your data types right.

And if you’re not sure what encoding to use? Start with ASCII for readable fields and BCD for numbers — unless your spec says otherwise.

Further Reading / References

  • ISO 8583 Wikipedia
  • EMV Book 3: Application Specification
  • Vendor-specific specs (e.g., Visa Base I, MasterCard M-TIP)