Base64 Encode / Decode
Base64 (RFC 4648) encode / decode
Client-side computation for analysis, verification, and learning. Do not paste production secrets into untrusted sites; prefer local tooling for key material.
Educational / engineering use. RSA mode uses tiny primes for illustration only—not for real key generation.
SGVsbG8sIOS4lueVjA==
Add Base64 Encode / Decode Free On Your Website
Paste this HTML on your site.
What is Base64 Encode / Decode?
Base64 converts binary data into a plain ASCII string using 64 printable characters. Commonly used to safely transmit binary content like images or files through text-based channels such as email or JSON APIs.
Base64 Formula
Every 3 bytes (24 bits) become four 6-bit groups:
output length = ceil(n/3) × 4 characters
Each 6-bit value maps to Base64 alphabet [A–Z, a–z, 0–9, +, /].
Padding "=" is added when input length is not a multiple of 3.
Step-by-Step
- Read input data as bytes.
- Group bits in 24-bit chunks.
- Split into 6-bit values.
- Map values to Base64 alphabet.
- Add padding "=" when needed.
Worked Example
Input: "Man"
Binary bytes: 01001101 01100001 01101110
Split into 6-bit groups -> decimal indices: 19, 22, 5, 46
Map using Base64 alphabet: 19->T, 22->W, 5->F, 46->u
Decoding reverses these steps.
Where Base64 Encode / Decode Is Applied
- Embedding images in HTML/CSS (data:image/png;base64,...)
- Email attachments encoding (MIME standard)
- Storing binary data in JSON and XML payloads
- JWT token structure (header and payload are Base64url encoded)
- Basic HTTP Authentication (Authorization: Basic header)
- Encoding cryptographic keys and certificates (PEM format)
- Storing binary blobs in databases that only support text
Related Cryptography Calculators
Explore similar calculators to streamline your workflow.