VALIDPDF417

AAMVA payload structure

The full byte layout, the subfile grammar, the offset and length arithmetic, and one annotated payload with every byte labelled.

The file at a glance

An AAMVA DL/ID file is a fixed-shape header followed by one or more subfiles. This encoder emits one DL subfile. With one entry the header is 21 bytes, the directory entry is 10 bytes, and the subfile begins at byte 31 with its two-byte designator. The length field counts that designator and everything after it.

PartBytesValue in this implementation
Compliance indicator1@ (0x40)
Data element separator10x0A
Record separator10x1E
Segment terminator10x0D
File type5ANSI , trailing space included
Issuer identification number6Per jurisdiction, zero-padded
AAMVA version210
Jurisdiction version200
Number of entries201
Directory entry: designator2DL
Directory entry: offset4Decimal, from byte 0 of the file
Directory entry: length4Decimal, counting the designator, the elements and the closing 0x0D
Two bytes, two different traps The offset is measured from the first byte of the file, not from the end of the header. The length includes the two-byte designator and the closing 0x0D. Get either wrong and a reader that trusts the field will fail even though the bytes are all present.

Header structure, byte by byte

OffsetLengthFieldCheck
01Compliance indicator0x40
11Data element separator0x0A
21Record separator0x1E
31Segment terminator0x0D
45File typeANSI
96Issuer identification numberMust equal the jurisdiction in DAJ
152AAMVA version10
172Jurisdiction version00
192Number of entries01
212Directory entry: designatorDL
234Directory entry: offset0031
274Directory entry: lengthComputed, not templated

The header ends at byte 30. Byte 31 is the first byte of the subfile: the two-byte designator, followed immediately by the first element. The offset and the length are not repeated inside the subfile. A second copy is read as an element, and a reader that expects DAQ at that position parses DL0 instead.

Subfile designator grammar

The directory entry is four fields and it is always 10 bytes. The subfile it points at begins with the designator and goes straight into elements:

grammar
entry      := designator 2 ASCII chars   "DL" for a driver's licence
              offset     4 decimal digits byte position of this designator
              length     4 decimal digits 2 + len(body)
subfile    := designator 2 ASCII chars   repeats the entry's designator
              body                       element*, then 0x0D
body       := element*                    each element ends 0x0A
              0x0D                       segment terminator
element    := 3 ASCII characters          AAMVA element identifier
              value                      uppercase; only DAK is padded

The designator value space is not just DL: ID is used for an identification card subfile. This encoder always emits DL, matching the DL subfile it builds. A reader that expects ID for a non-driver credential will not find it here.

Offset and length, worked line by line

Take a California record. The header is 31 bytes because every field in the table above is present and fixed-width. The body is the concatenation of elements, each ending in 0x0A, plus the final 0x0D.

arithmetic
header_len   = 4 + 5 + 6 + 2 + 2 + 2  # compliance, ANSI, IIN, version, jurisdiction version, entry count
             = 21

directory_len = 2 + 4 + 4              # designator, offset, length
             = 10

offset       = header_len + directory_len
             = 31

body_len     = sum(len(code) + len(value) + 1 for each element) + 1
             = 275                      # for the California sample below

sub_len      = 2 + body_len            # designator + elements + 0x0D
             = 277

file_len     = offset + sub_len
             = 31 + 277
             = 308

length_field = 0277                    # zero-padded to four digits
offset_field = 0031                    # zero-padded to four digits

The wrong version of this arithmetic counts the preamble as 12 bytes, producing 0430. The symbol still encodes, the checksum still passes, and a reader that bounds the record by the length field reads two bytes of the next structure. That is the classic silent corruption.

Element identifiers

Each element is a three-character ID, its value and a 0x0A terminator. The subfile ends with 0x0D. Values are uppercase. DAK is space-filled to 11 characters on v10; no other value is padded.

This is the table the encoder validates against, and it is published in full at /schema/fields.json. The per-jurisdiction IIN, required set and revision are at /schema/jurisdictions.json.

IDFieldFormat
DAQCustomer ID numberalphanumeric
DCSFamily nameup to 40, truncation flagged
DACGiven nameup to 40, truncation flagged
DADMiddle nameoptional
DBBDate of birthMMDDYYYY on v02+; CCYYMMDD on v01
DBAExpiry dateMMDDYYYY on v02+; CCYYMMDD on v01
DBDIssue dateMMDDYYYY on v02+; CCYYMMDD on v01
DBCSex1 male, 2 female, 9 unspecified
DAGStreet addressalphanumeric
DAICityalphanumeric
DAJJurisdiction code2 letters, derived from state
DAKPostal code5 or 9 digits, space-filled to 11 on v10
DCFDocument discriminatorjurisdiction-assigned
DCKInventory control numberjurisdiction-assigned
DDACompliance typeF or N
DDBCard revision dateCCYYMMDD
DDDLimited duration flag1 or 0
DDE DDF DDGName truncationT or N
DDKOrgan donor indicator0 or 1
DDLVeteran indicator0 or 1

Truncation semantics: DDE, DDF, DDG

DDE is the family name, DDF the given name and DDG the middle name. Each holds T when the value on the card is longer than the value stored in the symbol, and N when it fits.

The flag is the only signal a reader gets that a name was cut. A 42-character family name stored as 40 characters with DDE=N is not a cosmetic issue: the reader reports a complete name that is two characters short, and any downstream comparison against the card fails without explaining why. If your source data can exceed the cap, derive the flag from the source length, not from the value you sent.

DCF: the document discriminator

DCF is a jurisdiction-assigned value that changes when the card is reissued. It is not derived from the licence number, the date of birth or the expiry date. The common defect is copying DCF from a sample payload: the symbol is structurally perfect and identifies the wrong document.

The same rule applies to DCK, the inventory control number. Both are assigned by the jurisdiction. The API can mint a deterministic placeholder when generate.dd or generate.icn is set: a 12-character DCF from A-Z 2-9 with I, O, 0 and 1 removed, and a 12-digit DCK. That placeholder is suitable for fixtures and is not the identifier printed on the card. An explicit value always wins.

DDA: the compliance flag

DDA is F for a REAL ID compliant card and N for a non-compliant one. It is a copy of the card's status, not a property you can infer from the presence of an address or a photograph. A reader may treat the two values differently, so a wrong flag changes the meaning of the credential without breaking the symbol.

An annotated sample payload

Control characters are shown as glyphs: ␊ is 0x0A, ␞ is 0x1E, ␍ is 0x0D. The offsets below are byte positions in the encoded file.

payload · CA
offset 0     @                         compliance indicator
offset 1     ␊                         data element separator
offset 2     ␞                         record separator
offset 3     ␍                         segment terminator
offset 4     ANSI                      file type marker, 5 bytes with space
offset 9     636014                    IIN, California
offset 15    10                        AAMVA version
offset 17    00                        jurisdiction version
offset 19    01                        one entry
offset 21    DL                        directory: subfile designator
offset 23    0031                      directory: subfile offset
offset 27    0277                      directory: subfile length
offset 31    DL                        subfile designator, not repeated
offset 33    DAQ 1234567 ␊              customer ID
offset 44    DCS SAMPLE ␊               family name
offset 54    DAC JORDAN ␊               given name
offset 64    DBB 03141990 ␊             date of birth, MMDDYYYY
offset 76    DBA 01152030 ␊             expiry date
offset 88    DBC 1 ␊                    sex
offset 93    DAG 1234 SAMPLE ST ␊       street
offset 111   DAI BEVERLY HILLS ␊        city
offset 128   DAJ CA ␊                   jurisdiction code
offset 134   DAK 90210       ␊          postal code, space-filled to 11
offset 149   DCF QHCHQ8WX3J83 ␊         document discriminator
offset 165   DCK 123456789012 ␊         inventory control number
offset 181   DCA C ␊                    vehicle class
offset 186   DCB NONE ␊                 restrictions
offset 194   DCD NONE ␊                 endorsements
offset 202   DDA F ␊                    compliance type
offset 207   DDB 01012020 ␊             card revision date
offset 219   DDD 1 ␊                    limited duration
offset 224   DDE N ␊                    family name truncation
offset 229   DDF N ␊                    given name truncation
offset 234   DDG N ␊                    middle name truncation
offset 239   DBD 01152024 ␊             issue date
offset 251   DAY BRO ␊                  eye colour
offset 258   DAU 070 IN ␊               height
offset 268   DCG USA ␊                  country
offset 275   DDK 0 ␊                    organ donor indicator
offset 280   DDL 0 ␊                    veteran indicator
offset 285   DAD A ␊                    middle name
offset 290   DAZ BRO ␊                  hair colour
offset 297   DAW 165 LB ␊               weight
offset 307   ␍                         segment terminator

Two checks catch almost every defect on this structure. First, the two bytes at the offset field must be DL; if they are not, the offset is wrong. Second, offset + length must equal the total byte count; if it does not, the length was measured from the wrong place.

Verify a payload

Paste a payload into the barcode inspector for a byte table, IIN lookup and a pass or fail per rule. For the substrate side of the same problem, read error correction.

Generate barcode now