Bitcoin Private Key Formats Explained
To the human eye, a Bitcoin private key is just a long string of random characters. However, those characters can be represented in several different formats depending on the software or use case. Understanding these formats is crucial for importing keys or building Bitcoin applications.
1. The Raw Format: Hexadecimal (Hex)
At its core, a Bitcoin private key is simply a 256-bit number. In its rawest computer-readable form, it is often shown as a Hexadecimal string.
- Structure: 64 characters consisting of numbers (0-9) and letters (A-F).
- Example:
1E99423A4ED27608A15A2616A2B0E9E52CED330AC530EDCC32C8FFC6A526AEDD - Use Case: Mostly used by developers and in low-level cryptographic libraries.
2. Wallet Import Format (WIF)
Because raw Hex strings are long and easy to misspell, the Wallet Import Format (WIF) was created. It is shorter, includes built-in error checking, and is the standard format for importing keys into wallet software.
- Encoding: It uses Base58Check encoding (which excludes confusing characters like 0, O, I, and l).
- Structure: Starts with the number
5(for uncompressed keys). - Error Detection: It includes a 4-byte checksum. If you mistype a character, the wallet will tell you the key is invalid.
3. WIF-Compressed
With the introduction of compressed public keys, a new version of WIF was needed. Despite the name, the private key isn't actually smaller; the "compressed" label tells the wallet to derive a compressed public key from it.
- Structure: Starts with
KorL. - Example:
KwDiBf89QB8BD21mZEDCr1wkXonrurRQCpGLzdG67ZAzBnVLUnJi - Why it matters: Using a compressed WIF key results in a different (smaller) Bitcoin address than an uncompressed one. Most modern wallets use this by default to save on transaction fees.
4. Comparison Table
| Format | Length | Start Character | Description |
|---|---|---|---|
| Hex | 64 chars | Variable | Raw 256-bit number in base 16. |
| WIF | 51 chars | 5 |
Base58 encoded, uncompressed. |
| WIF-Compressed | 52 chars | K or L |
Base58 encoded, for compressed pubkeys. |
5. Converting Between Formats
Converting a Hex key to WIF involves: 1. Adding a version byte (0x80 for mainnet). 2. (Optional) Adding a compression flag (0x01). 3. Calculating a double-SHA256 checksum and appending the first 4 bytes. 4. Encoding the entire result into Base58.
Why Format Matters for Your Balance
If you import a private key into a wallet and the balance shows 0, but you know there are funds on it, you might be using the wrong format. A single private key can generate a Legacy (1...) address or a SegWit (bc1...) address. Ensure your wallet is checking the correct address type for the format you imported.
Our Bitcoin key explorer shows keys in WIF format, making them easy to visualize and understand. Browse the pages to see the diversity of WIF strings.