# Hexadecimal

Hex writes each byte as two characters from 0-9 and a-f. Learn to read hashes, keys and raw transactions, and convert numbers with our tool.

Canonical page: https://mybitcoinexplorer.com/learn/hexadecimal
Topic: Cryptography
Published: 2026-10-29
Updated: 2026-10-30


## Counting in sixteens
Normal numbers use 10 digits. **Hexadecimal** (base 16) uses 16: `0–9` then `a–f` for 10 to 15.

| Decimal | Hex | Binary |
|---|---|---|
| 0 | 0 | 0000 |
| 9 | 9 | 1001 |
| 10 | a | 1010 |
| 15 | f | 1111 |
| 255 | ff | 1111 1111 |

## One byte = two hex characters
A byte holds values from 0 to 255, which is exactly `00` to `ff`. That's why:
- a 32-byte hash is 64 hex characters,
- a 20-byte public key hash is 40,
- a 33-byte public key is 66.

## Try it
> Interactive exercise: [open the lesson](https://mybitcoinexplorer.com/learn/hexadecimal).

Bitcoin stores many numbers in reverse byte order; the converter above shows both. See [Bytes and endianness](https://mybitcoinexplorer.com/learn/bytes-and-endianness).


## Converting by hand
To turn hex `1f` into decimal: `1` × 16 + `f` (15) = 31. For longer numbers, each position is worth 16 times the one to its right, just as each decimal place is worth 10 times.

## Common Bitcoin values in hex
| Value | Hex | Where |
|---|---|---|
| 1 BTC in sats | 05f5e100 | Output amounts |
| Block 840,000 | 0cd140 | Coinbase height |
| OP_RETURN | 6a | Data outputs |
| OP_CHECKSIG | ac | End of most scripts |


## Key takeaways

- Hex is base 16, using 0–9 and a–f.
- Every byte is exactly two hex characters.
- Hashes, keys and raw transactions are usually shown in hex.

## Common questions

### Is 0x part of the number?

No. 0x is a prefix that says 'this is hex'.

### Are uppercase and lowercase hex the same?

Yes. A and a both mean 10.

### Why does Bitcoin use hex instead of normal numbers?

Hex maps cleanly to bytes, so binary data like hashes and scripts stays readable and exact.

### Is 0x part of the hex number?

No, it's just a prefix that marks the number as hexadecimal.

## Related lessons

- [Bytes and endianness](https://mybitcoinexplorer.com/learn/bytes-and-endianness)
- [Hash functions](https://mybitcoinexplorer.com/learn/hash-functions)
- [Anatomy of a raw transaction](https://mybitcoinexplorer.com/learn/anatomy-of-a-raw-transaction)
- [Transaction IDs (txid)](https://mybitcoinexplorer.com/learn/transaction-id-txid)
