Base64 Reference

Complete Base64 alphabet: 64 characters mapping 6-bit values (0-63) to ASCII text

Back to all tools on ToolForge

More in Developer Tools

Base64 Alphabet Table

IndexCharBinary (6-bit)IndexCharBinary (6-bit)

Padding: = used when output length is not a multiple of 4 (not part of encoding alphabet).

About Base64 Reference

This Base64 reference table shows the complete character alphabet used in Base64 encoding. Each of the 64 characters maps to a specific 6-bit value (0-63), enabling conversion between binary data and ASCII text representation.

Base64 Character Set Structure

Character Range Index Range Count Pattern
A-Z (uppercase) 0-25 26 Sequential ASCII uppercase
a-z (lowercase) 26-51 26 Sequential ASCII lowercase
0-9 (digits) 52-61 10 Sequential ASCII digits
+ (plus) 62 1 Special character
/ (slash) 63 1 Special character

Base64 Encoding Algorithm

Converting binary data to Base64 text:

  1. Group input: Split binary into groups of 3 bytes (24 bits each)
  2. Split to 6-bit: Each 24-bit group becomes four 6-bit values
  3. Map to alphabet: Each 6-bit value (0-63) becomes one Base64 character
  4. Add padding: If final group has 1 or 2 bytes, add = padding to reach multiple of 4
Example: Encoding "ABC" (ASCII: 65, 66, 67)

Step 1: Convert to binary
  A = 65  = 01000001
  B = 66  = 01000010
  C = 67  = 01000011

Step 2: Concatenate bits
  01000001 01000010 01000011

Step 3: Split into 6-bit groups
  010000 010101 000010 01000011
     16     21      2     17

Step 4: Map to Base64 alphabet
  16→Q, 21→V, 2→C, 17→R

Result: "QVJD" (4 characters from 3 bytes)

Base64 Encoding Examples

Input Text Bytes Base64 Output Padding
"" (empty) 0 "" None
"A" 1 (65) QQ== 2 chars (=)
"AB" 2 (65, 66) QUI= 1 char (=)
"ABC" 3 (65, 66, 67) QUJD None
"Hello" 5 SGVsbG8= 1 char (=)
"Hello World" 11 SGVsbG8gV29ybGQ= 1 char (=)

Standard Base64 vs Base64URL

Standard Base64 uses + and / which have special meaning in URLs. Base64URL (RFC 4648 Section 5) replaces these for safe URL usage:

Variant Index 62 Index 63 Padding Use Case
Standard (RFC 4648 §4) + / Required Email (MIME), general data
Base64URL (RFC 4648 §5) - _ Optional JWT, OAuth, URLs, filenames
Conversion Example:

Standard:  SGVsbG8+V29ybGQ/
Base64URL: SGVsbG8-V29ybGQ_

Characters replaced:
  + → - (plus to hyphen)
  / → _ (slash to underscore)

Size Overhead Calculation

Base64 encoding increases data size:

Input Size Calculations:

Input Bytes   → Base64 Chars   → Overhead
1             → 4 (QQ==)       → 300%
2             → 4 (QUI=)       → 100%
3             → 4              → 33.3%
100           → 136            → 36%
1,000         → 1,336          → 33.6%
10,000        → 13,336         → 33.4%
1,000,000     → 1,333,336      → 33.3%

Note: Overhead approaches 33.3% for larger inputs

File Type Detection (Magic Bytes)

The first few bytes of binary data identify the file format. In Base64, these appear as characteristic prefixes:

Format Magic Bytes (hex) Base64 Prefix MIME Type
PNG 89 50 4E 47 0D 0A 1A 0A iVBORw0KGgo image/png
JPEG FF D8 FF /9j/ image/jpeg
GIF 47 49 46 38 39 61 R0lGODlh image/gif
WebP 52 49 46 46 UklGR image/webp
BMP 42 4D Qk image/bmp
PDF 25 50 44 46 2D JVBERi0 application/pdf
ZIP 50 4B 03 04 UEsDB application/zip

Common Applications

How to Use This Reference

  1. Look up characters: Find any Base64 character and its corresponding index (0-63).
  2. Understand binary: See the 6-bit binary representation for encoding/decoding manually.
  3. Verify encoding: Check that Base64 output uses only valid alphabet characters.
  4. Debug issues: Identify invalid characters or padding problems in Base64 strings.

Quick Reference

Frequently Asked Questions

What is the Base64 character set?
Base64 uses 64 characters: uppercase A-Z (indices 0-25), lowercase a-z (indices 26-51), digits 0-9 (indices 52-61), plus + (index 62), and forward slash / (index 63). The padding character = is not part of the encoding alphabet but is used to ensure output length is a multiple of 4.
How does Base64 encoding work?
Base64 processes binary data in 6-bit groups. Each 6-bit value (0-63) maps to one character in the Base64 alphabet. Three input bytes (24 bits) are split into four 6-bit groups, producing four Base64 characters. If input length isn't divisible by 3, padding characters (=) are added.
What is URL-safe Base64 (Base64URL)?
URL-safe Base64 replaces + with - (hyphen) and / with _ (underscore) to make the output safe for URLs and filenames. This variant is used in JWT tokens, OAuth parameters, and file identifiers. Padding is often omitted in Base64URL to avoid URL encoding issues.
Why does Base64 use 6 bits per character?
Six bits provides exactly 64 unique values (2^6 = 64), which matches the 64-character alphabet. This enables efficient encoding where 3 bytes (24 bits) convert to exactly 4 Base64 characters with no wasted bits. Using fewer bits would limit the character set; using more would require multiple characters per byte.
How is Base64 padding calculated?
Padding ensures output length is a multiple of 4. For 1 input byte (8 bits): encode to 2 Base64 chars (12 bits used, 4 bits unused) + 2 padding = 4 chars total. For 2 input bytes (16 bits): encode to 3 Base64 chars (18 bits used, 2 bits unused) + 1 padding = 4 chars total. For 3+ bytes divisible by 3: no padding needed.
What are the magic bytes for detecting file types in Base64?
File format magic bytes appear at the start of Base64 data: PNG starts with iVBORw0K (hex: 89 50 4E 47), JPEG with /9j/ (hex: FF D8 FF), GIF with R0lGOD (hex: 47 49 46 38), WebP with UklGR (hex: 52 49 46 46), and BMP with Qk (hex: 42 4D). These prefixes help identify the correct MIME type when decoding.