Skip to content
encode2026-07-252 min read

What Is Base32/Base58 Encoding

Base32 and Base58 are encoding formats that convert binary data to readable text strings. They are variants of Base64 optimized for different scenarios.

Encoding Format Comparison

| Encoding | Character Set | Case | Checksum | Typical Use | |----------|--------------|------|----------|-------------| | Base64 | A-Z, a-z, 0-9, +, / | Case-sensitive | None | HTTP, Email | | Base32 | A-Z, 2-7 | Uppercase | Optional | TOTP/HOTP, DNS | | Base58 | 1-9, A-H, J-N, P-Z, a-k, m-z | Mixed | Built-in | Bitcoin, IPFS |

Why Choose Base32/Base58

Base32 Advantages:

  • Human-readable (uppercase letters and digits only)
  • Suitable for dictation and handwriting (avoids confusing chars like 0/O, 1/l/I)
  • Standard encoding for TOTP/HOTP authentication codes

Base58 Advantages:

  • Removes confusing characters (0, O, I, l)
  • Standard encoding for Bitcoin addresses
  • Built-in checksum prevents transcription errors

How to Use an Online Tool

Using DevToolkit Pro's Base32/Base58 Encoder:

  1. Input raw text or binary data
  2. Select target encoding format (Base32/Base58/Base64)
  3. Real-time encoding result display
  4. Supports reverse decoding operation
  5. One-click copy encoding result

Encoding in Code

JavaScript

// Base32 Encoding
function base32Encode(buffer) {
  const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
  let bits = '';
  for (const byte of buffer) {
    bits += byte.toString(2).padStart(8, '0');
  }
  let result = '';
  for (let i = 0; i < bits.length; i += 5) {
    const chunk = bits.substr(i, 5).padEnd(5, '0');
    result += alphabet[parseInt(chunk, 2)];
  }
  return result;
}

// Base58 Encoding (commonly used in Bitcoin)
function base58Encode(buffer) {
  const alphabet = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
  let num = BigInt('0x' + Array.from(buffer).map(b => b.toString(16).padStart(2, '0')).join(''));
  let result = '';
  while (num > 0n) {
    const [quotient, remainder] = [num / 58n, num % 58n];
    result = alphabet[Number(remainder)] + result;
    num = quotient;
  }
  // Handle leading zeros
  for (const byte of buffer) {
    if (byte === 0) result = '1' + result;
    else break;
  }
  return result;
}

Python

import base64

# Base32 Encoding
def base32_encode(data: bytes) -> str:
    return base64.b32encode(data).decode('ascii')

# Base58 Encoding (requires additional library)
# pip install base58
import base58
def base58_encode(data: bytes) -> str:
    return base58.b58encode(data).decode('ascii')

FAQ

What's the Difference Between Base32 and Base64?

Base32 uses only uppercase letters and digits 2-7 (32 characters), while Base64 uses mixed case letters, digits, and +/ (64 characters). Base32 is more human-friendly but less space-efficient (~80% vs Base64's 75% overhead).

Why Does Bitcoin Use Base58 Instead of Base64?

Base58 removes confusing characters (0/O/I/l). Bitcoin addresses need to be manually entered or transcribed without errors. Additionally, Base58 has a built-in checksum that detects input mistakes.

How to Choose an Encoding Format?

  • HTTP/API data transfer → Base64
  • TOTP codes, DNS → Base32
  • Bitcoin addresses, IPFS → Base58
  • High human readability → Base32

This article is brought to you by DevToolkit Pro. More developer tools at the homepage.


ad