Base58 Encoder/Decoder: Convert Text, Hex, and Bitcoin Addresses
Encode and decode Base58 and Base58Check strings used in Bitcoin addresses. Supports text-to-Base58, hex-to-Base58, and address validation with checksum verification.
What Is Base58 Encoding?
Base58 is a binary-to-text encoding scheme designed specifically for cryptocurrency use cases. It encodes arbitrary binary data into a compact, human-readable string using a carefully chosen 58-character alphabet. Unlike hexadecimal (which uses 16 characters) or Base64 (which uses 64 characters plus padding), Base58 strikes a balance between compactness and readability by intentionally excluding characters that are easy to confuse with one another.
The encoding was introduced by Satoshi Nakamoto in Bitcoin's original codebase. It converts a byte array into a big integer, then repeatedly divides by 58 to produce digits in the Base58 alphabet. Each leading zero byte in the input maps to a leading "1" character in the output, preserving the distinction between, for example, a 20-byte payload and a 21-byte payload that starts with 0x00.
Base58 is not a general-purpose encoding like Base64. It lacks padding characters, is not designed for fixed-width output, and is slower to encode and decode because it relies on arbitrary-precision arithmetic rather than simple bitwise operations. Its purpose is narrow: producing short, unambiguous strings for use in addresses and keys where humans need to read, copy, and communicate values without error.
Why Bitcoin Uses Base58
Before Bitcoin, most cryptographic identifiers were represented in hexadecimal. A 20-byte hash becomes a 40-character hex string, which is long and easy to mistype. Satoshi chose Base58 to make Bitcoin addresses shorter and less error-prone. A 25-byte Base58Check address encodes to roughly 34 characters, compared to 50 characters in hex.
The key design decision was removing four characters from the standard Base64 alphabet: the digit zero (0), the uppercase letter O, the uppercase letter I, and the lowercase letter l. In many fonts, these characters are nearly indistinguishable from each other (0 vs O, I vs l). By eliminating them, Base58 reduces the risk of transcription errors when users manually copy addresses from screens, printed QR code labels, or verbal communication.
Base58 also omits the plus sign (+) and forward slash (/) found in Base64, which can cause problems in URLs, filenames, and double-click text selection. This means a Base58 string can be safely embedded in a URL without percent-encoding, pasted into a terminal without escaping, and double-clicked to select the entire string in most text editors.
Base58 vs Base64
While both are binary-to-text encodings, Base58 and Base64 serve different purposes and have different trade-offs. The following table summarizes the key differences across common encoding schemes.
| Property | Base58 | Base64 | Hex | Base32 |
|---|---|---|---|---|
| Alphabet size | 58 | 64 + padding | 16 | 32 |
| Characters used | Alphanumeric (no 0, O, I, l) | A-Z, a-z, 0-9, +, / | 0-9, a-f | A-Z, 2-7 |
| Padding | None | = signs | None | = signs |
| Case sensitive | Yes | Yes | No | No |
| Size efficiency (20 bytes) | ~27 chars | 28 chars | 40 chars | 32 chars |
| Encoding speed | Slow (BigInt math) | Fast (bitwise) | Fast (bitwise) | Fast (bitwise) |
| URL safe | Yes | No (needs encoding) | Yes | Yes |
| Primary use | Bitcoin addresses, keys | Email, data URIs | Low-level data | TOTP codes, file names |
Base58Check: Adding Checksums
Raw Base58 encoding has no built-in error detection. If a user mistypes a single character, the decoded result is simply different data with no indication that an error occurred. Base58Check solves this by appending a 4-byte checksum before encoding.
The Base58Check format works as follows: take the payload (which includes a version byte prefix), compute the double SHA-256 hash of the versioned payload, take the first 4 bytes of that hash as the checksum, append those 4 bytes to the versioned payload, and then Base58-encode the entire result. When decoding, the process is reversed: Base58-decode the string, split off the last 4 bytes as the checksum, recompute the double SHA-256 of the remaining bytes, and verify that the first 4 bytes of the hash match the extracted checksum.
This checksum provides strong error detection. A single-character typo in a Base58Check string has approximately a 1 in 4.3 billion chance of accidentally producing a valid checksum. In practice, this means virtually every transcription error is caught before funds are sent to an invalid address.
Base58 in Bitcoin Addresses
Bitcoin uses Base58Check encoding for legacy address formats. The version byte prefix determines the address type, and the decoded payload contains the hash that identifies the recipient.
| Version byte | Prefix | Address type | Example start |
|---|---|---|---|
| 0x00 | Mainnet P2PKH | Pay-to-Public-Key-Hash | 1... |
| 0x05 | Mainnet P2SH | Pay-to-Script-Hash | 3... |
| 0x6F | Testnet P2PKH | Testnet address | m... or n... |
| 0xC4 | Testnet P2SH | Testnet script hash | 2... |
| 0x80 | WIF private key | Wallet Import Format | 5... or K... or L... |
| 0x0488B21E | xpub | Extended public key (BIP32) | xpub... |
| 0x0488ADE4 | xprv | Extended private key (BIP32) | xprv... |
Modern Bitcoin addresses (those starting with bc1) use Bech32 or Bech32m encoding instead of Base58Check. These newer formats offer better error detection and are optimized for QR codes, but Base58Check addresses remain widely used and fully supported by the Bitcoin network.
The Base58 Alphabet
The Base58 alphabet consists of exactly 58 characters, ordered as follows:
123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz
The index of each character maps to its numeric value. The character "1" represents 0, "2" represents 1, and so on through "z" which represents 57. This ordering is why Bitcoin addresses that start with "1" correspond to version byte 0x00: the leading zero byte maps to the first character in the alphabet.
The four excluded characters are: the digit 0 (easily confused with the letter O), the uppercase letter O (easily confused with the digit 0), the uppercase letter I (easily confused with the lowercase letter l and the digit 1), and the lowercase letter l (easily confused with the uppercase letter I and the digit 1). This deliberate omission is the defining feature of Base58 and the primary reason it exists as a separate encoding from Base64.
Frequently Asked Questions
What is Base58 encoding used for?
Base58 encoding is primarily used in Bitcoin and other cryptocurrencies for representing addresses, private keys in Wallet Import Format (WIF), and extended keys (xpub/xprv). It produces compact, human-readable strings that avoid visually ambiguous characters. Outside of cryptocurrency, Base58 is sometimes used for generating short unique identifiers, file hashes, and URL-safe tokens.
What characters are excluded from Base58?
Base58 excludes four characters from the standard alphanumeric set: the digit 0, the uppercase letter O, the uppercase letter I, and the lowercase letter l. These characters are removed because they look similar to each other in many typefaces, which could lead to transcription errors when users manually copy or read addresses.
What is the difference between Base58 and Base58Check?
Base58 is the raw encoding algorithm that converts bytes to a string using the 58-character alphabet. Base58Check adds a version byte prefix and a 4-byte checksum (derived from double SHA-256 hashing) before encoding. The checksum allows the decoder to detect typos and corruption. Bitcoin addresses use Base58Check, not raw Base58.
How does Base58 handle leading zeros?
Leading zero bytes (0x00) in the input data are encoded as leading "1" characters in the Base58 output. This is handled separately from the main encoding algorithm because the BigInt division approach would otherwise lose leading zeros. For Bitcoin addresses, the version byte 0x00 (P2PKH mainnet) produces the characteristic leading "1" in the address.
Can Base58 encoding be reversed?
Yes. Base58 is an encoding, not a hash function or encryption algorithm. It is fully reversible: given a Base58-encoded string, you can always recover the exact original bytes. The decoder converts each character back to its numeric value, reconstructs the big integer, and converts it back to a byte array, restoring any leading zero bytes based on leading "1" characters.
Why is Base58 slower than Base64?
Base64 operates on fixed groups of 6 bits using simple bitwise operations (shifting and masking), which is extremely fast. Base58 requires arbitrary-precision integer arithmetic: the entire input is treated as one large number that must be repeatedly divided by 58 to extract each output digit. This division over large integers is significantly slower than bitwise operations, especially for long inputs.
Do modern Bitcoin addresses still use Base58?
Legacy Bitcoin addresses (starting with 1 or 3) use Base58Check encoding. However, modern SegWit addresses (starting with bc1) use Bech32 or Bech32m encoding, which was introduced in BIP173 and BIP350. Bech32 addresses are case-insensitive and have stronger error detection properties. Both formats are valid on the Bitcoin network, and Base58Check addresses will continue to be supported indefinitely.
Is Base58 encoding the same across all cryptocurrencies?
The Base58 alphabet and encoding algorithm are the same across most cryptocurrencies that use it, including Bitcoin, Litecoin, and Dash. However, the version bytes used in Base58Check differ between networks. For example, a Litecoin P2PKH address uses version byte 0x30 (starting with L), while Bitcoin uses 0x00 (starting with 1). The encoding itself is identical; only the prefixed metadata changes.
This tool runs entirely in your browser. No data is sent to any server. Spark does not store, transmit, or have access to any values you enter. Always verify critical outputs independently.
Build with Spark
Integrate bitcoin, Lightning, and stablecoins into your app with a few lines of code.
Read the docs →
