Base64 Encoder / Decoder
Encode text to Base64 or decode Base64 back to text. Handles Unicode (emoji, non-English text) correctly.
What Is a Base64 Encoder?
Base64 is the internet's universal adapter: it rewrites binary data — images, files, raw bytes — using only 64 safe characters (A–Z, a–z, 0–9, +, /) that survive any text system intact. This tool encodes text to Base64 and decodes Base64 back to text, in both directions, with copy and clear controls. Developers reach for it when debugging APIs, embedding small images in code, inspecting tokens, and moving data through systems that only accept plain text.
The need for Base64 is historical and permanent. Email was designed for 7-bit ASCII text; attachments became possible only when MIME taught email to encode binary files as text — Base64. The same trick now powers data URIs in CSS, embedded images in HTML, basic web authentication headers, JSON web tokens' segments, and countless API payloads. If you have copied a string ending in one or two "=" signs that looked like alphabet soup, you have met it.
How to Use the Base64 Encoder
- Paste or type your content into the box — plain text to encode, or a Base64 string to decode.
- Click "Encode → Base64" or "Decode ← Base64" as appropriate.
- The result replaces the content; use Copy to grab it or Clear to start again.
How Base64 Works
Encoding takes the input three bytes at a time (24 bits) and splits them into four 6-bit groups, each mapped to one character of the 64-character alphabet. That is why Base64 output is always a multiple of four characters and about 33% larger than the input — the price of text-safety. When the input length is not a multiple of three, "=" padding completes the final group: one "=" means one byte is missing, two means two. So "M" becomes "TQ==", "Ma" becomes "TWE=", and "Man" becomes "TWFu" — the example used in the original specification documents.
Important: Base64 Is Not Encryption
- Anyone can decode Base64 instantly (this page just did) — never use it to protect passwords, keys, or private data.
- It provides zero integrity: encoded content can be altered and re-encoded without detection.
- Its legitimate superpower is transport compatibility, not secrecy — treat decoded content from strangers with the same caution as any file.
Why does Base64 text get longer?
Because each Base64 character carries only 6 bits of information while a byte holds 8 — encoding four characters to transport three bytes means the output is 4/3 the input size, a fixed ~33% overhead, plus padding. That is the accepted cost of making binary data safe for text-only channels; for small payloads like tokens and icons it is trivial, for huge files the overhead is why Base64 is avoided in bulk transfer.
What is a Base64 data URI used for?
A data URI embeds a file directly inside HTML or CSS — src="data:image/png;base64,..." — so the browser needs no separate download. It suits tiny, critical graphics (small icons, placeholders) where saving a network request beats the 33% size penalty. For larger images it backfires: the encoded text inflates the document and cannot be cached separately, which is why data URIs stay a small-file technique.
My decode failed or produced gibberish. Why?
Usually one of three causes: the input is truncated (a copied string missing its tail or "=" padding), it contains characters outside the Base64 alphabet (line breaks are tolerated by some decoders, other stray characters are not), or it was never Base64 at all — hex and other encodings look superficially similar. Re-copy the complete string exactly, including any trailing "=".
Is there a difference between Base64 and Base64 URL-safe?
Yes, a small one: standard Base64 uses + and /, which have special meanings in URLs, so the URL-safe variant substitutes − and _ and often drops padding. JWTs and many web tokens use the URL-safe flavor. If a token decodes strangely, try swapping those two characters — or use a decoder that accepts both alphabets — before concluding the data is corrupt.