How to convert Base64 to Base58
- Paste the Base64 string into Input · Base64. Standard and URL-safe characters both work, and so do missing
=padding, line breaks and adata:prefix. - Read the result in Output · Base58.
- Pick the Alphabet under the output if the target is not Bitcoin-style Base58. Flickr and Ripple order the same 58 characters differently.
- Copy output, or click Base58 → Base64 in the direction toggle to go back. The Base58 to Base64 page starts in that direction.
The conversion goes through the raw bytes: Base64 is decoded, and the bytes are encoded as Base58. Nothing is added or removed, so a 32-byte key stays a 32-byte key.
Examples
| Base64 | Base58 | What it is |
|---|---|---|
SGVsbG8= | 9Ajdvzr | The text Hello |
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= | 11111111111111111111111111111111 | 32 zero bytes: the Solana System Program |
Bt324ddloZPZy+FGzut5rBy0he1fWzeROoz1hX7/AKk= | TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA | Solana SPL Token program ID |
Bt324ddloZPZy-FGzut5rBy0he1fWzeROoz1hX7_AKk | TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA | Same key as URL-safe Base64 without padding |
The last two rows are the same 32 bytes in two Base64 spellings, so both give the same Base58.
Building an IPFS CIDv0 from a SHA-256 digest
A CIDv0 is Base58 of a multihash: the bytes 12 (SHA-256) and 20 (32 bytes long), then the digest. Many tools print a SHA-256 digest as Base64, and converting that alone does not give a Qm… string:
| Bytes | Base64 | Base58 |
|---|---|---|
| Digest only | JiqGtnblhp7dXRrfj/0B1inDFUv96uz8jPoNkOCILYo= | 3Zz6yE7jDUVDb6doCEWrK58or4X2TmTLBiJeyWY4NHvq |
12 20 + digest | EiAmKoa2duWGnt1dGt+P/QHWKcMVS/3q7PyM+g2Q4Igtig== | QmQudp5N7EzTxrBk3yESEKyEroMYNd7R22G2KWffwNZyzq |
The EiA at the start of the second Base64 string is the encoded 12 20 header, so a Base64 multihash is easy to recognize. To add the header yourself, convert the digest with Base64 to hex, put 1220 in front, and encode the hex on the Base58 page with From set to Hex.
This only helps when you already have the digest IPFS computed. IPFS hashes a file’s UnixFS block, not the raw file, so running sha256sum on a file does not reproduce its CID.
Length: Base64 vs Base58
| Bytes | Base64 | Base58 (random data) |
|---|---|---|
| 16 | 24 | 21 or 22 |
| 20 | 28 | 26 to 28 |
| 32 | 44 | 43 or 44 |
| 64 | 88 | 87 or 88 |
Base64 length depends only on the byte count. Base58 length also depends on the value, which is why Solana addresses vary between 32 and 44 characters. Do not validate Base58 by exact length.
The same conversion in JavaScript
Node.js decodes Base64 natively; the Base58 half needs a BigInt:
const ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
function base64ToBase58(b64) {
const bytes = Buffer.from(b64, "base64");
let n = BigInt("0x" + (bytes.toString("hex") || "0"));
let out = "";
while (n > 0n) {
out = ALPHABET[Number(n % 58n)] + out;
n /= 58n;
}
for (const b of bytes) {
if (b !== 0) break;
out = "1" + out;
}
return out;
}
base64ToBase58("Bt324ddloZPZy+FGzut5rBy0he1fWzeROoz1hX7/AKk=");
// 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'
Buffer.from(…, "base64") also accepts URL-safe input. The function relies on Node’s Buffer; Base64 in Node.js covers it in more detail.
FAQ
Can I convert Base64 to Base58 without decoding to bytes?
Not character by character. Base64 maps fixed 6-bit groups, while Base58 treats all the bytes as one number, so every converter, this page included, decodes the Base64 to bytes first and re-encodes those bytes.
Why is the Base58 result sometimes shorter than the Base64?
Base58 has no padding and leading zero bytes cost one character each. 32 bytes are always 44 Base64 characters (with =), but 43 or 44 in Base58, and only 32 when all bytes are zero.
Which Base58 alphabet does Solana use?
The Bitcoin alphabet, which is the default here. Flickr and Ripple are under Alphabet if you need them.
Why doesn't my Base58 output start with Qm?
Qm comes from the 2-byte multihash header 12 20. If your Base64 holds only the 32-byte SHA-256 digest, prepend those two bytes first, as described on this page.