Dev & Computing · Base64 编码(Base64) · Updated 2026-10-25
What Is Base64 Encoding?
Definition
Base64 re-slices every 3 bytes (24 bits) into four 6-bit groups, each mapped to A-Z/a-z/0-9/+/, padding with = when short. Use cases: carrying binary through text-only channels (HTTP headers, JSON, email — image data URLs, JWTs). The cost is +33% size (4/3) — pushing large base64 blobs through JSON is a classic performance incident. The URL-safe variant swaps +/ for -_. Remember: base64 is encoding, not encryption — anyone can decode it without a key.
Formula
Encoded length = ceil(n/3) × 4; 3n bytes → 4n characters
Worked Example
"Man" = 77,97,110 → 010011 010110 000101 101110 → "TWFu"; a 1MB image becomes ~1.37MB in base64 — prefer object storage over JSON blobs.
Common Misconception
"base64 encrypts data" — it only re-represents it; decoding needs no key. And "data URLs beat img requests" — one less request but a bloated document with no independent caching; images over 2KB belong behind URLs.
Matching Calculators
Related Terms
Keep Exploring
Browse the full glossary, or head back to the homepage for 1,435 free online calculators.
Back to glossary