Base58 encoder and decoder

Base58 with the Bitcoin alphabet, as repeated division of one big number by 58, with leading zero bytes.

How it works

Base58 writes bytes with 58 characters: the digits and letters without 0, O, I and l, which are easy to confuse, and without + and /, so that a double click selects the whole string. It was made for Bitcoin addresses, which people copy by hand.

Since 58 is not a power of 2, the bits cannot simply be cut into groups. Instead all the bytes are read as one big number $N$ (big-endian, base 256) and written in base 58, by dividing by 58 again and again: the remainders are the digits, last digit first. Each leading zero byte would vanish in the number, so it is written as the character 1 (the digit for 0).

Decoding goes the other way, with Horner’s rule $N \leftarrow 58N + d$. The repeated division makes Base58 slow for long data, but addresses and keys are short. Bitcoin adds a 4-byte checksum (Base58Check, the first bytes of a double SHA-256) before encoding.

Everything is calculated in your browser. Nothing you type leaves your device.