Base64 Encoder/Decoder

Why Binary Data Needs a Text-Safe Wrapper

Base64 exists because many systems — email, JSON payloads, URLs, older text-only protocols — can't safely carry arbitrary binary bytes. Base64 encoding maps every 3 raw bytes into 4 printable ASCII characters drawn from a 64-character alphabet (A–Z, a–z, 0–9, +, /), so the data survives being copy-pasted, embedded in a text file, or passed through systems that only handle plain text.

The Formula

Encode: Base64 = base64(UTF-8 bytes of input text)
Decode: Text = UTF-8 text of decoded Base64 bytes

Because each Base64 character represents 6 bits of information rather than a full byte, encoded output is always roughly 33% larger than the original data — every 3 bytes of input becomes 4 characters of output, with padding (=) added if the input length isn't a multiple of 3.

Worked Example

Encoding a short string
FieldValue
Input textHello, World!
UTF-8 byte length13 bytes
Base64 outputSGVsbG8sIFdvcmxkIQ==
Base64 length20 characters

13 bytes encodes to 20 Base64 characters — consistent with the roughly 4:3 expansion ratio, since 13 bytes rounds up to 15 (5 groups of 3) before the final group gets padded.

Where This Matters

  • Embedding binary data in JSON or XML — APIs that need to transmit images, files, or cryptographic keys inside a text-based payload typically Base64-encode them first.
  • Data URIs — small images and fonts embedded directly in CSS or HTML via data: URIs are Base64-encoded so the browser can parse them as part of the surrounding text.
  • Basic authentication headers — HTTP Basic Auth encodes the "username:password" pair as Base64 before sending it in the Authorization header (note: this is encoding, not encryption, and offers no security on its own).

How to Use This Calculator

  1. Choose a mode: Encode Text to Base64 or Decode Base64 to Text.
  2. Enter or paste the text into the input field.
  3. Select Calculate to see the encoded or decoded result along with byte and character counts.

Related Calculations

Check the size of a JSON payload before encoding it with the JSON Size Calculator, or generate identifiers for your data with the UUID Generator.