Blockchain Hex Converter
Convert between hexadecimal, decimal, binary, and text formats
Hexadecimal in Blockchain
Hexadecimal (base-16) is fundamental to blockchain technology. It provides a compact way to represent binary data and is used throughout blockchain systems for addresses, transaction hashes, contract bytecode, and more.
Why Hexadecimal?
Blockchain systems use hexadecimal because:
- Compact Representation: More readable than binary, more compact than decimal
- Byte Alignment: Two hex digits exactly represent one byte
- Easy Conversion: Simple conversion to/from binary
- Standard Format: Universal in cryptography and computing
Common Blockchain Uses
Addresses
Ethereum addresses are 20-byte (40-character) hexadecimal values:
0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb0
Transaction Hashes
Transaction identifiers are 32-byte (64-character) hashes:
0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef
Function Selectors
Smart contract function calls use 4-byte (8-character) selectors:
0xa9059cbb // transfer(address,uint256)
Token Amounts
Large token amounts are often displayed in hexadecimal:
0xde0b6b3a7640000 // 1 ETH in Wei (decimal: 1000000000000000000)
Number Systems Comparison
Same Value in Different Bases
| System | Base | Digits | Example (255) |
|---|---|---|---|
| Binary | 2 | 0-1 | 11111111 |
| Octal | 8 | 0-7 | 377 |
| Decimal | 10 | 0-9 | 255 |
| Hexadecimal | 16 | 0-9, A-F | FF |
Hex Notation
Hexadecimal uses digits 0-9 and letters A-F (or a-f) to represent values 0-15:
- 0-9: Represent values 0-9
- A-F: Represent values 10-15
- 0x prefix: Indicates hexadecimal (e.g., 0xFF = 255)
- Case insensitive: 0xFF = 0xff
Text Encoding
ASCII
ASCII is a character encoding standard using 7 bits per character. Common in simple text representations:
"Hello" = 0x48656c6c6f
UTF-8
UTF-8 supports international characters using variable-length encoding (1-4 bytes per character):
"Hello 🌍" = 0x48656c6c6f20f09f8c8d
Practical Applications
1. Debugging Transactions
Convert hex input data to text to understand what data was sent in a transaction.
2. Encoding Messages
Convert text to hex for signing messages or storing data on-chain.
3. Analyzing Bytecode
Smart contract bytecode is in hexadecimal format.
4. Token ID Conversion
NFT token IDs are often in hex format and need conversion for display.
Conversion Examples
Example Conversions
Hex to Decimal:
0xFF = 15×16¹ + 15×16⁰ = 240 + 15 = 255
Decimal to Hex:
255 ÷ 16 = 15 remainder 15 = 0xFF
Text to Hex:
"Hi" = H(72) i(105) = 0x4869
Quick Reference
Hex Digits
- 0-9 = 0-9
- A = 10
- B = 11
- C = 12
- D = 13
- E = 14
- F = 15
Common Prefixes
- 0x: Hex (most common)
- 0o: Octal
- 0b: Binary
Byte Sizes
- 1 byte: 2 hex digits
- 4 bytes: 8 hex digits
- 20 bytes: 40 hex (address)
- 32 bytes: 64 hex (hash)
- 256 bits: 64 hex digits