Base64 Encoder / Decoder

Encode and decode text using Base64.

Share

About the Base64 Encoder / Decoder

Base64 is a way of writing arbitrary binary data using only 64 printable ASCII characters. It exists because a lot of the internet's older plumbing - email headers, HTTP basic auth, JSON payloads, XML documents, URL query strings - was designed to carry text, and will corrupt or drop raw bytes that fall outside a narrow safe range. Encoding those bytes as Base64 first guarantees they survive the trip.

This encoder and decoder runs entirely in your browser. Nothing you paste is uploaded, logged, or sent to a server, which matters when the string you are debugging happens to contain a session token, an API response, or a customer record.

How to use this tool

  1. Pick Encode to turn readable text into Base64, or Decode to go the other way.
  2. Paste or type your input into the upper box. The result appears below as you type - there is no submit button.
  3. When decoding, choose the charset the original bytes were written in. UTF-8 is correct for almost everything produced this century.
  4. Use the swap arrows to move the result into the input box, which is handy for verifying a round trip.
  5. Click the copy icon on the output box to put the result on your clipboard.

How Base64 encoding actually works

The encoder reads your input three bytes at a time. Three bytes is 24 bits, which divides evenly into four 6-bit groups, and each 6-bit group has 64 possible values - hence the name. Each group is looked up in an alphabet of A-Z, a-z, 0-9, plus, and slash to produce one output character.

Because four output characters represent three input bytes, Base64 always inflates data by roughly 33%. When the input length is not a multiple of three, the final group is padded with one or two `=` characters so decoders know how many bytes to discard. That is why so many Base64 strings end in `=` or `==`, and why a string whose length is not a multiple of four is usually a sign of truncation.

Base64 is not encryption

This is the single most common misunderstanding about Base64, and it has caused real breaches. Base64 is a reversible, keyless, public transformation. Anyone who sees the string can decode it in a second - including with this page. It provides no confidentiality whatsoever.

If you need to protect a secret, you need encryption with a key. Our text encryption tool covers the symmetric and asymmetric cases. Use Base64 only for what it is designed for: making binary data safe to transport through text-only channels.

Where you will run into it

JWT tokens are three Base64url-encoded segments joined by dots, which is why you can decode a JWT's header and payload without any secret at all. HTTP Basic authentication sends `username:password` as a single Base64 string. Data URIs embed images directly in CSS or HTML as Base64. Email attachments have been Base64-encoded since MIME was standardised. Kubernetes Secrets store their values Base64-encoded in YAML - encoded, note, not encrypted.

Frequently asked questions

Why does my decoded output look like garbage?
Usually a charset mismatch. If the original bytes were UTF-8 text and you decode as Latin-1, multi-byte characters split into pairs of accented nonsense. Try UTF-8 first. If every charset produces garbage, the input probably was not text to begin with - it may be a compressed archive, an image, or an encrypted blob.
What is Base64url, and is it different?
Yes, slightly. Standard Base64 uses `+` and `/`, both of which have special meaning in URLs. Base64url swaps them for `-` and `_` and usually drops the `=` padding. JWTs and many OAuth flows use Base64url. If a token will not decode here, try replacing `-` with `+` and `_` with `/` first.
Is there a size limit?
Only your browser's memory. Because the work happens locally there is no upload cap, but very large inputs will make the page feel sluggish since encoding runs on the main thread as you type.
Does the charset option affect encoding too?
No. Encoding always reads your text as UTF-8, which is what the browser gives us. The charset selector applies when decoding, where we have to decide how to interpret the recovered bytes as characters.