Smart Card APDU Decoder
Use this Smart Card APDU Decoder to break hexadecimal command APDUs into CLA, INS, P1, P2, Lc, command data and Le fields. The calculator supports short and extended APDU structures and identifies common ISO 7816-style instruction codes where a generic name is useful.
| Field | Offset | Length | Hex | Decimal / Meaning |
|---|
-
-
What Is a Smart Card APDU?
APDU stands for Application Protocol Data Unit. Smart-card communication commonly exchanges command APDUs from a terminal or reader to a card and response APDUs from the card back to the terminal.
A command APDU begins with a four-byte header containing CLA, INS, P1 and P2. Depending on the command case, the header can be followed by a command-data length field, command data and an expected response length.
Command APDU Structure
CLA INS P1 P2 [Lc] [Data] [Le]
Not every command contains every optional field. The combination of Lc, data and Le determines the APDU case.
APDU Header Fields
| Field | Size | Purpose |
|---|---|---|
| CLA | 1 byte | Instruction class and class-dependent control information |
| INS | 1 byte | Instruction code |
| P1 | 1 byte | Instruction parameter 1 |
| P2 | 1 byte | Instruction parameter 2 |
| Lc | Optional | Number of command data bytes |
| Data | Optional | Command payload |
| Le | Optional | Maximum or expected response data length |
What Is CLA?
CLA is the command class byte. It helps identify the instruction class and can also carry class-dependent information such as logical-channel or secure messaging indicators.
The exact interpretation of every CLA bit depends on the card environment and instruction class, so this decoder displays the raw byte and a conservative structural interpretation rather than guessing proprietary meaning.
What Is INS?
INS is the instruction byte. Many commonly encountered command codes have well-known generic names.
| INS | Common Instruction |
|---|---|
| A4 | SELECT |
| B0 | READ BINARY |
| B2 | READ RECORD |
| D6 | UPDATE BINARY |
| DC | UPDATE RECORD |
| 20 | VERIFY |
| 24 | CHANGE REFERENCE DATA |
| 2C | RESET RETRY COUNTER |
| 84 | GET CHALLENGE |
| 82 | EXTERNAL AUTHENTICATE |
| 88 | INTERNAL AUTHENTICATE |
| C0 | GET RESPONSE |
An application can define additional or proprietary commands, so an unknown INS value is not automatically an invalid APDU.
P1 and P2 Parameters
P1 and P2 are command-specific parameter bytes. Their meaning depends on the INS value and the smart-card application.
00 A4 04 00 ...
INS = A4 → SELECT
P1 = 04
P2 = 00
For a SELECT command, those bytes may describe the selection method and response options, but the decoder keeps them explicitly visible rather than applying a protocol profile the user did not select.
APDU Case 1
Case 1 consists only of the four-byte command header.
CLA INS P1 P2
Example:
00 A4 00 00
There is no command data and no expected-response-length field.
APDU Case 2
Case 2 has no command data but includes Le, indicating an expected or maximum response-data length.
CLA INS P1 P2 Le
For a short APDU, one Le byte is used.
00 B0 00 00 10
CLA = 00
INS = B0
P1 = 00
P2 = 00
Le = 16
Short APDU Lc
In a short APDU with command data, the byte after P2 contains Lc. Lc gives the number of following command-data bytes.
00 D6 00 00 03 01 02 03
Lc:
03
Data:
01 02 03
This is a Case 3S APDU because command data is present but no Le follows.
APDU Case 4
Case 4 contains both command data and Le.
CLA INS P1 P2 Lc Data Le
A common SELECT-by-AID example is:
00 A4 04 00
07
A0 00 00 00 03 10 10
00
The Lc byte declares seven command-data bytes and the final byte is Le.
Short APDU vs Extended APDU
Short APDU
Uses one-byte Lc or Le fields and normally supports command-data lengths up to 255 bytes.
Extended APDU
Uses an extended marker and two-byte length fields to represent larger command or response lengths.
Extended APDU Encoding
When the first byte following the four-byte header is 00, the
command may use the extended-length form.
Depending on the remaining bytes, the following two bytes can represent extended Le or extended Lc.
CLA INS P1 P2
00
LcHi LcLo
Data...
[LeHi LeLo]
The decoder distinguishes this structure from ordinary short APDU Lc parsing.
Le Value of Zero
A zero Le byte in a short command APDU does not normally mean that zero bytes are requested. It represents the maximum value available in the short Le encoding, conventionally interpreted as 256.
Le byte:
00
Decoded short Le:
256
Likewise, an extended Le field of 0000 represents the maximum
extended expected length of 65536.
SELECT APDU Example
00 A4 04 00 07
A0 00 00 00 03 10 10
00
This structure decodes as:
CLA = 00
INS = A4
SELECT
P1 = 04
P2 = 00
Lc = 7
Data =
A0 00 00 00 03 10 10
Le =
00 → 256
Case =
4S
READ BINARY APDU Example
00 B0 00 00 10
This is structurally a Case 2S APDU:
CLA = 00
INS = B0
P1 = 00
P2 = 00
Le = 16
No command-data field is present.
GET CHALLENGE APDU Example
00 84 00 00 08
The INS value 84 is commonly used for GET CHALLENGE. The command
contains no input data and requests eight response bytes.
Case 2S
Le = 8
Command APDU vs Response APDU
Command APDU
Sent to the card. It contains CLA, INS, P1, P2 and optionally Lc, data and Le.
Response APDU
Returned by the card. It normally contains optional response data followed by status bytes SW1 and SW2.
This page focuses specifically on command APDU decoding. A separate response-status decoder can interpret SW1/SW2 values without mixing two different tool purposes.
Why APDU Length Validation Matters
If Lc says seven bytes of command data follow, the command must provide seven bytes before any optional Le field can be interpreted.
Lc = 07
Required data:
7 bytes
A decoder that merely splits bytes visually can incorrectly treat a missing data byte as Le. This calculator checks the actual remaining length before assigning fields.
Common APDU Decode Errors
Less Than Four Bytes
A command APDU cannot contain a complete CLA / INS / P1 / P2 header.
Lc Larger Than Data
The declared command-data length exceeds the bytes available in the APDU.
Unexpected Extra Bytes
More bytes remain than are valid for the detected APDU case.
Incomplete Extended Length
An extended-length marker is present but not enough length bytes follow.
Ambiguous Application Meaning
Structural bytes are valid but the instruction semantics require the card application’s documentation.
Confusing Response Status
SW1/SW2 belong to a response APDU and should not be interpreted as command APDU fields.
Smart Card APDU Decoder FAQs
What does APDU stand for?
What are CLA, INS, P1 and P2?
What is Lc in an APDU?
What is Le in an APDU?
What is an APDU Case 1 command?
What is APDU Case 2?
What is APDU Case 3?
What is APDU Case 4?
What does APDU INS A4 mean?
What does APDU INS B0 mean?
What does APDU INS 84 mean?
What does APDU INS C0 mean?
What does short APDU Le 00 mean?
What is an extended APDU?
Can APDU command data contain TLV?
Is an unknown INS value invalid?
Does this decoder interpret SW1 and SW2?
Can this decoder read extended Lc and Le?
Decode Smart Card Command APDUs
Paste hexadecimal APDU bytes to inspect the command class, instruction, parameters, command-data length, payload, expected response length and short or extended APDU case with byte-level validation.