Base58 Decode String
Decode Base58-encoded strings to text, hex, or decimal bytes. Supports Bitcoin Base58 alphabet with real big-integer arithmetic.
About
Base58 encoding is a binary-to-text scheme designed to represent large integers as compact, human-readable strings. It uses an alphabet of 58 characters that deliberately excludes visually ambiguous glyphs: zero (0), uppercase O, lowercase l, and uppercase I. This prevents transcription errors when addresses or identifiers are read aloud or handwritten. The encoding is not a simple positional mapping. Each input character carries a weight of 58n, and decoding requires arbitrary-precision integer division across the full byte array. A naive lookup table will not suffice. Incorrect decoding of a cryptocurrency address means funds sent to a non-existent destination with zero possibility of recovery.
This tool implements the Bitcoin Base58 alphabet (123456789ABCDEFGH...xyz) with real big-integer arithmetic on byte arrays. It preserves leading zero bytes encoded as the character 1. Output is available as UTF-8 text, hexadecimal, or decimal byte values. Note: this decoder does not validate Base58Check checksums. If you need checksum verification for Bitcoin addresses, validate the trailing 4 bytes separately against a double SHA-256 hash of the payload.
Formulas
Base58 decoding converts a string of characters from the Base58 alphabet into a sequence of raw bytes. The process treats the input as a base-58 number and converts it to base-256 (bytes).
value = nโ1โi=0 charValuei ร 58(nโ1โi)
Where n is the length of the input string, charValuei is the integer value (0 - 57) of the i-th character in the Base58 alphabet. The accumulated integer is then converted to a big-endian byte array. Leading 1 characters (value 0) in the input map to leading 0x00 bytes in the output.
Algorithm steps:
1. Count leading 1 characters โ leadingZeros
2. For each remaining character, multiply accumulator by 58, add charValue
3. Convert accumulator to bytes (repeated division by 256)
4. Prepend leadingZeros zero bytes
Where charValue = indexOf(char) in the alphabet string 123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz. If any character is not found in the alphabet, the input is invalid.
Reference Data
| Character | Value | Character | Value | Character | Value | Character | Value |
|---|---|---|---|---|---|---|---|
| 1 | 0 | G | 15 | X | 31 | o | 47 |
| 2 | 1 | H | 16 | Y | 32 | p | 48 |
| 3 | 2 | J | 17 | Z | 33 | q | 49 |
| 4 | 3 | K | 18 | a | 34 | r | 50 |
| 5 | 4 | L | 19 | b | 35 | s | 51 |
| 6 | 5 | M | 20 | c | 36 | t | 52 |
| 7 | 6 | N | 21 | d | 37 | u | 53 |
| 8 | 7 | P | 22 | e | 38 | v | 54 |
| 9 | 8 | Q | 23 | f | 39 | w | 55 |
| A | 9 | R | 24 | g | 40 | x | 56 |
| B | 10 | S | 25 | h | 41 | y | 57 |
| C | 11 | T | 26 | i | 42 | - | |
| D | 12 | U | 27 | j | 43 | - | |
| E | 13 | V | 28 | k | 44 | - | |
| F | 14 | W | 29 | m | 45 | - | |
| Excluded characters: 0 (zero), O (uppercase O), I (uppercase I), l (lowercase L) | |||||||
| Alphabet origin: Bitcoin (Satoshi Nakamoto, 2009). Also used by IPFS, Monero, Ripple (with modified alphabet), Flickr short URLs. | |||||||
| Base58Check: Payload + first 4 bytes of SHA-256(SHA-256(payload)). Used in Bitcoin addresses, WIF private keys. | |||||||
| Encoding ratio: ~1.37 Base58 characters per input byte (vs 1.33 for Base64) | |||||||
| Max address length (Bitcoin P2PKH): 34 characters, starting with 1 | |||||||
| Max address length (Bitcoin P2SH): 34 characters, starting with 3 | |||||||