APDU Smart Card Command Utility

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.

✓ CLA / INS ✓ P1 / P2 ✓ Lc + Data ✓ Le ✓ Extended APDU
C-APDU
Decode Smart Card APDU
● Ready
Enter hexadecimal command APDU bytes. Spaces, commas, colons, hyphens and 0x prefixes are accepted. The first four bytes are interpreted as CLA / INS / P1 / P2.
Important: this decoder interprets the structural command APDU fields. Exact meanings of CLA bits, INS, P1/P2 parameters and command data can vary by smart-card application, secure-messaging profile and proprietary instruction set. The raw bytes remain the source of truth.
Smart Card APDU Result Decoded
Decoded Command APDU
APDU Case
APDU Length
CLA
INS
P1
P2
Lc
Data Length
Le
Length Encoding
Instruction
Structure Status
Field Offset Length Hex Decimal / Meaning
APDU Byte-Level Breakdown -
Normalized APDU Bytes
-

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
A4SELECT
B0READ BINARY
B2READ RECORD
D6UPDATE BINARY
DCUPDATE RECORD
20VERIFY
24CHANGE REFERENCE DATA
2CRESET RETRY COUNTER
84GET CHALLENGE
82EXTERNAL AUTHENTICATE
88INTERNAL AUTHENTICATE
C0GET 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?
APDU stands for Application Protocol Data Unit.
What are CLA, INS, P1 and P2?
They are the four mandatory command-header bytes: class, instruction, parameter 1 and parameter 2.
What is Lc in an APDU?
Lc indicates how many command-data bytes are present.
What is Le in an APDU?
Le represents the expected or maximum response-data length requested by the command.
What is an APDU Case 1 command?
Case 1 contains only CLA, INS, P1 and P2 with no command data and no Le.
What is APDU Case 2?
Case 2 has no command-data field but contains Le.
What is APDU Case 3?
Case 3 contains Lc and command data but no Le.
What is APDU Case 4?
Case 4 contains both command data and an Le field.
What does APDU INS A4 mean?
A4 is commonly used for the SELECT instruction.
What does APDU INS B0 mean?
B0 is commonly used for READ BINARY.
What does APDU INS 84 mean?
84 is commonly used for GET CHALLENGE.
What does APDU INS C0 mean?
C0 is commonly used for GET RESPONSE.
What does short APDU Le 00 mean?
In short Le encoding, 00 represents 256 rather than zero expected response bytes.
What is an extended APDU?
An extended APDU uses extended length fields so command or response lengths can exceed the limits of the short one-byte length representation.
Can APDU command data contain TLV?
Yes. Many smart-card applications place BER-TLV or proprietary data structures inside APDU data, but the APDU layer itself only defines the command-data boundary.
Is an unknown INS value invalid?
Not necessarily. Applications and card platforms can define proprietary instructions.
Does this decoder interpret SW1 and SW2?
No. SW1 and SW2 are response APDU status bytes. This page focuses on command APDU structure.
Can this decoder read extended Lc and Le?
Yes. It distinguishes supported short and extended command APDU cases and validates the available byte count.

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.

Scroll to Top