Hex Converter — Hex / Decimal / Binary / Octal
Convert between hexadecimal, decimal, binary, and octal number systems. Supports signed/unsigned integers up to 64-bit, ASCII ↔ hex byte conversion, and visual bit display. All computation in-browser — your data never leaves your device.
Bit View
How Hexadecimal Works
Hexadecimal (base-16) is the lingua franca of low-level computing and smart card engineering. Each hex digit represents exactly 4 bits (a nibble), so one byte is always two hex digits. This makes it trivial to read binary data: 0xFF = 255 = 11111111 in binary.
0xC8 in hex — instantly readable as one byte. In smart card APDUs, EMV TLV data, and cryptographic keys, every value is expressed in hex because each pair of digits maps perfectly to one byte on the wire.Number Base Reference
| Base | Name | Digits Used | Prefix | Example (decimal 255) |
|---|---|---|---|---|
| 2 | Binary | 0, 1 | 0b | 0b11111111 |
| 8 | Octal | 0–7 | 0o / 0 | 0377 |
| 10 | Decimal | 0–9 | (none) | 255 |
| 16 | Hexadecimal | 0–9, A–F | 0x | 0xFF |
Smart Card Use Cases
| Scenario | Example | Notes |
|---|---|---|
| EMV Tag 9F02 Authorized Amount | 000000011934 → $119.34 | 12-digit BCD, n6 padded. Two digits per byte, last 2 = cents |
| APDU status word SW1 SW2 | 0x9000 (success), 0x6A82 (file not found) | Always 2 bytes, big-endian |
| AID (Application Identifier) | A0000000041010 (Mastercard) | 5-16 bytes, RID + PIX, big-endian |
| ATR historical bytes | 3B ... 8031E073FE21123456782900 | Variable length, protocol info |
| Cryptographic key (3DES) | 0123456789ABCDEFFEDCBA9876543210 | 16 bytes = 32 hex chars (double-length DES key) |
| Bit masks / flags | 0xFF00 = high byte set, low byte clear | Common in access bits, capability flags |
EMV Amount Encoding (BCD)
EMV Tag 9F02 (Amount, Authorized) is stored as a 6-byte BCD (Binary-Coded Decimal) value. Each nibble represents one decimal digit. For example, $119.34 is encoded as 00 00 00 01 19 34 — 6 bytes, 12 nibbles, where the last 2 digits are the decimal portion (cents).
Signed vs Unsigned (Two's Complement)
When interpreting a hex value as a signed integer, the most significant bit (MSB) determines the sign. If the MSB is 1, the value is negative and computed via two's complement:
Examples (8-bit): 0x7F = 0111 1111 = +127 (max positive) 0x80 = 1000 0000 = -128 (min negative) 0xFF = 1111 1111 = -1 0x00 = 0000 0000 = 0 For n-bit two's complement: if MSB == 1: value = -(2^n - unsigned_value)
Endianness
Multi-byte integers can be stored big-endian (most significant byte first) or little-endian (least significant byte first). Smart card protocols (EMV, ISO 7816, GlobalPlatform) almost universally use big-endian. x86 CPUs and many ARM implementations use little-endian.
| Value | Big-endian (EMV/network) | Little-endian (x86) |
|---|---|---|
| 0x1234ABCD | 12 34 AB CD | CD AB 34 12 |
| 0x0000FFFF | 00 00 FF FF | FF FF 00 00 |
Use the "Swap Endian" button to reverse byte order — useful when converting between smart card data (big-endian) and x86 memory dumps (little-endian).
Related Tools
- EMV Tag Lookup — Search EMVCo tags by hex value (9F02, 5A, 57, ...)
- EMV TLV Parser — Parse BER-TLV TLV data containing hex-encoded EMV tags
- APDU Command Builder — Build APDUs with hex command data
- CRC Calculator — Compute CRC checksums on hex input
- Base64 Encoder / Decoder — Convert hex bytes to/from Base64
- BER-TLV Parser — Parse raw hex BER-TLV structures