Toolzent

Base64 Encode and Decode

Free Base64 decode and encode tool. Convert text to Base64 or decode Base64 to text instantly, UTF-8 safe, in your browser. Nothing is uploaded.

Updated 2026-06-09 · Free · No sign-up · Runs privately in your browser

Base64 output

What is Base64 Encode and Decode?

Base64 encoding rewrites any text or binary data using just 64 safe characters, and decoding reverses it back to the original. This tool does both: the Encode tab turns text into a Base64 string, and the Decode tab turns a Base64 string back into readable text. It is UTF-8 safe, runs entirely in your browser, and is built for moving data through systems that only accept plain text.

What does this tool do?

It converts in two directions. Encode takes your text and outputs Base64; Decode takes Base64 and outputs the original text. Switching tabs relabels the boxes so you always know which side is the input. The output box updates live as you type or paste, and a Copy button puts the result on your clipboard. If you paste something that is not valid Base64 while decoding, it shows a clear error instead of a wrong answer.

How does it work?

Base64 maps every 3 bytes (24 bits) of input to 4 characters drawn from a fixed 64-character alphabet: A-Z, a-z, 0-9, + and /. Because 64 equals 2 to the power 6, each output character carries exactly 6 bits, and 4 of them carry the 24 bits of three input bytes.

When the input length is not a multiple of 3, the final group is padded with = signs so the output length is always a multiple of 4. One leftover byte produces two characters plus ==; two leftover bytes produce three characters plus a single =.

This tool is UTF-8 safe by construction. Internally it encodes with btoa(unescape(encodeURIComponent(text))), which first expands accented and non-ASCII characters into their UTF-8 bytes so nothing is mangled. Decoding does the exact reverse with decodeURIComponent(escape(atob(input))), and whitespace in the pasted Base64 is ignored. Base64 only re-expresses bytes as text — it is not encryption and provides no secrecy.

Examples

Here are three encodes you can reproduce exactly in the tool. Each one shows how the bytes group into characters.

Example 1: “Man” becomes TWFu. The three letters are a perfect 3-byte group, so there is no padding.

  • M a n are 3 bytes (24 bits).
  • Re-split into four 6-bit chunks, they map to T W F u.
  • Result: Man becomes TWFu.

Example 2: “hi” becomes aGk=. Two bytes is not a multiple of three, so one = pad appears.

  • h i are 2 bytes, which fill three Base64 characters: a G k.
  • The missing third byte is shown as a single =.
  • Result: hi becomes aGk=.

Example 3: “Hello, Toolzent!” becomes SGVsbG8sIFRvb2x6ZW50IQ==. This is the tool’s default text. It is 16 bytes, leaving one byte over, so it ends in ==.

  • 16 bytes split into five full 3-byte groups (15 bytes) plus 1 leftover byte.
  • The leftover byte produces two characters and == padding.
  • Result: Hello, Toolzent! becomes SGVsbG8sIFRvb2x6ZW50IQ==.

Decoding reverses each one: paste TWFu, aGk= or SGVsbG8sIFRvb2x6ZW50IQ== into the Decode tab and you get Man, hi and Hello, Toolzent! back. A UTF-8 case works too: café encodes to Y2Fmw6k= and decodes straight back to café.

The Base64 alphabet

Every Base64 character stands for a 6-bit value from 0 to 63. This is the complete index table, plus the two special markers. It is the standard alphabet (RFC 4648), which is exactly what this tool uses.

IndexCharIndexCharIndexCharIndexChar
0A16Q32g48w
1B17R33h49x
2C18S34i50y
3D19T35j51z
4E20U36k520
5F21V37l531
6G22W38m542
7H23X39n553
8I24Y40o564
9J25Z41p575
10K26a42q586
11L27b43r597
12M28c44s608
13N29d45t619
14O30e46u62+
15P31f47v63/

Beyond index 63, = is used only as padding and never carries data.

Common uses

Base64 appears anywhere binary data has to travel through a text-only channel. Common situations include:

  • Developers embed small images or fonts directly in CSS and HTML as data: URIs, send binary file contents inside JSON APIs, and read the payload portion of a JWT (which is Base64Url, a close relative).
  • Email systems encode attachments with Base64 under MIME so 8-bit files survive mail servers that expect plain text.
  • Designers paste a Base64 data: string for an icon into a stylesheet to avoid a separate network request for a tiny asset.
  • Students and learners use it to see exactly how bytes map to characters when studying encoding, character sets, or how = padding is calculated.

If you are working with colours or raw bits alongside this, the hex to rgb converter and binary translator cover the neighbouring conversions.

Tips and common mistakes

A handful of misunderstandings cause most Base64 problems:

  • Base64 is not encryption. It hides nothing. Anyone can paste your string into this tool and read it, so never treat it as a way to secure passwords or secrets.
  • Padding is meaningful. The = characters are part of valid output. Stripping them can break strict decoders, and seeing == simply means the input length left one byte over.
  • It is not compression. The output is about 33% larger than the input, because 3 bytes always become 4 characters. Expect 12 bytes to grow to 16 characters.
  • Whitespace while decoding is fine. This tool ignores spaces and line breaks in the pasted Base64, so multi-line strings copied from emails or files still decode correctly.
  • Mind the alphabet variant. Standard Base64 uses + and /. URLs and JWTs use Base64Url, which swaps those for - and _; pasting Base64Url here may fail or shift bytes.

Limitations and notes

This tool uses the standard Base64 alphabet, so it does not auto-translate the Base64Url variant (- and _) used in some tokens and URLs. Decoding rejects anything outside A-Z, a-z, 0-9, +, / and = with an error rather than guessing. Extremely large inputs are limited only by your browser’s memory, since everything runs locally. Most importantly, the encoding and decoding happen entirely in your browser with JavaScript — your text is never uploaded, logged, or stored, which makes it safe for sensitive snippets and offline use once the page has loaded.

For related developer conversions, try the binary translator, the UUID generator, or the hex to rgb converter, and browse the full Dev & Tech tools collection.

Frequently asked questions

How do I decode a Base64 string?+

Click the Decode tab, paste your Base64 (for example SGVsbG8sIFRvb2x6ZW50IQ==), and the original text appears instantly below; whitespace is ignored automatically.

What does "hi" encode to in Base64?+

The text hi encodes to aGk= — two characters become four, and the trailing = is padding because hi is only two bytes, not a multiple of three.

Is Base64 encryption or a way to hide data securely?+

No. Base64 is a reversible encoding, not encryption. Anyone can decode it with this tool, so never use it to protect passwords or secrets.

Why does my encoded text end with one or two equals signs?+

The = signs are padding. Base64 works in 3-byte groups; if the last group has one byte you get ==, and two bytes gives a single =.

Why is my Base64 output longer than the original text?+

Base64 turns every 3 bytes into 4 characters, so the output is roughly 33% larger than the input. Eleven bytes become sixteen characters, for example.

Does this tool handle emoji and accented characters like café?+

Yes. It is UTF-8 safe, so café encodes to Y2Fmw6k= and decodes back perfectly. Each non-ASCII character expands to its multi-byte UTF-8 form first.

What happens if I paste invalid Base64?+

The decoder shows the message that the input is not valid Base64. Valid input uses only A-Z, a-z, 0-9, + and /, with optional = padding.

Is my text uploaded to a server when I encode or decode it?+

No. All encoding and decoding runs in your browser with JavaScript, so your text never leaves your device and nothing is stored or logged.