Skip to content
ToolMoose

Base64 Encode and Decode

Encode text to Base64 and decode it back, UTF-8 safe and fully in-browser.

Base64
SGVsbG8sIFdvcmxkIQ==

Worked examples

"Man" to Base64
Man encodes to TWFu. Three bytes (77, 97, 110) map cleanly to four Base64 characters, so there is no padding.
"Hi" to Base64
Hi encodes to SGk=. Two bytes leave a leftover group, so one = padding character is added to round the output to four characters.
"Hello, World!" to Base64
Hello, World! encodes to SGVsbG8sIFdvcmxkIQ==. The 13 bytes need two = padding characters to fill the final four-character block.
Decode SGVsbG8sIFdvcmxkIQ==
Switch to Decode and paste SGVsbG8sIFdvcmxkIQ== to get Hello, World! back. Whitespace and line breaks are stripped before decoding.

How Base64 encoding works

Base64 is a way of representing any data, text, images, or raw bytes, using a small set of printable characters. Many systems (email, URLs, JSON, older network protocols) were built to carry plain text and can choke on arbitrary bytes. Base64 sidesteps that by rewriting the data in a form that survives text-only channels intact. This tool converts in both directions, all in your browser.

What Base64 is and its 64-character alphabet

The name says it: Base64 uses 64 distinct characters to stand in for data. The standard alphabet is the 26 uppercase letters A to Z, the 26 lowercase letters a to z, the 10 digits 0 to 9, and two symbols, + and /. That is 64 characters, and each one represents a 6-bit value from 0 to 63.

Because bytes are 8 bits and Base64 characters are 6 bits, the two do not line up evenly. Base64 solves this by working in blocks: three bytes (24 bits) become exactly four Base64 characters (4 x 6 = 24 bits). When the input does not end on a clean three-byte boundary, the encoder pads the output with one or two = signs so the result is always a whole number of four-character blocks.

How 3 bytes map to 4 characters

The core trick is regrouping bits. Take three bytes, line up their 24 bits in a row, then slice that row into four groups of 6 bits instead of three groups of 8. Each 6-bit group is a number from 0 to 63, and you look it up in the alphabet above.

  • Three input bytes produce four characters with no padding.
  • Two input bytes (16 bits) produce three characters plus one =.
  • One input byte (8 bits) produces two characters plus two =.

That padding is why Base64 output length is always a multiple of four, and why short inputs end in =.

A worked example: β€œMan” to β€œTWFu”

Take the three letters Man. Their byte values are 77, 97, and 110.

  1. Write each byte in 8-bit binary: 01001101 (77), 01100001 (97), 01101110 (110).
  2. Join into a 24-bit row: 010011010110000101101110.
  3. Re-slice into four 6-bit groups: 010011 010110 000101 101110.
  4. Read each group as a number: 19, 22, 5, 46.
  5. Look up the alphabet: 19 is T, 22 is W, 5 is F, 46 is u.

So Man becomes TWFu, with no padding because three bytes filled the block exactly. Shorter inputs like Hi (two bytes) round out to SGk=, and Hello, World! (13 bytes) needs two padding signs, giving SGVsbG8sIFdvcmxkIQ==.

Encoding is not encryption

This is the most important caveat. Base64 is not encryption and offers no security. There is no key and no secret step. Anyone who sees a Base64 string can decode it instantly, exactly as this tool does. Its job is safe transport of data through text channels, not confidentiality. If you need to protect data, use real encryption; Base64 on top of that is fine, but Base64 alone hides nothing.

UTF-8 and Unicode handling

Base64 works on bytes, not letters, so the first step for text is deciding how letters become bytes. This tool uses UTF-8, the standard modern encoding. Plain English characters take one byte each, while accented letters take two and most emoji take four. The converter turns your text into UTF-8 bytes first, then Base64-encodes those bytes, so accented text and emoji round-trip perfectly. On decode it reverses both steps, rebuilding the exact original characters.

Common uses

Base64 shows up all over software:

  • Data URIs: small images and fonts can be embedded directly in HTML or CSS as data:image/png;base64,..., saving a network request.
  • Email attachments: the MIME standard uses Base64 to send binary files (images, PDFs) through email, which was designed for text.
  • APIs and tokens: JSON Web Tokens (JWTs) and many API payloads use Base64 (often the URL-safe variant) to package data compactly in text.
  • Config and storage: binary blobs such as keys or certificates are frequently stored as Base64 strings inside JSON, YAML, or environment variables.

In short, reach for Base64 whenever binary data needs to travel through something that expects plain text. Just remember it is a representation, not a lock.

Frequently asked questions

What is Base64 and why the = at the end?
Base64 is a way of writing binary data using only 64 printable characters (A to Z, a to z, 0 to 9, plus + and /). It works on groups of three bytes, turning each group into four characters. When the data does not divide evenly into groups of three, one or two = signs are added as padding so the output length is always a multiple of four.
Is Base64 encryption? Is it secure?
No. Base64 is encoding, not encryption. It has no key and no secret, so anyone can decode it in seconds. It only changes the representation of data so it can travel safely through text-only channels. Never use it to hide passwords or private information.
Does this handle Unicode, accents, and emoji?
Yes. The converter uses UTF-8, so accented letters and emoji are encoded byte for byte and survive a full round trip. An emoji becomes several bytes before it is turned into Base64, and decoding rebuilds the exact original characters.
Why did my decode fail?
Decoding fails when the input is not valid Base64: it contains characters outside the Base64 alphabet, the length is wrong, or the padding is broken. Copy-paste errors and truncated strings are common causes. The tool shows a short message instead of guessing, so check for stray characters or missing tail.
Is my data uploaded anywhere?
No. All encoding and decoding runs in your browser using built-in JavaScript. Nothing you type is sent to a server, logged, or stored, so it is safe to convert data you would rather keep private.

Last updated: 2026-07-02