Skip to content
Calcuplay
Tech

Base64 encoder and decoder

Base64 writes any data with 64 safe characters: "Man" becomes "TWFu". Every 3 bytes become 4 characters, so the result is about a third longer.

Quick challenge

Streak 0Best 0

Test yourself: every answer is computed by the tool, and the wrong choices are the most common traps.

How it works

Formula: Characters = 4 × ⌈bytes ÷ 3⌉

The text is first turned into bytes with UTF-8: one byte for a basic Latin letter, two to four for accented letters and emoji. The bytes are read 3 at a time, 24 bits cut into 4 groups of 6 bits; each group, from 0 to 63, picks a character among A–Z, a–z, 0–9, + and / (RFC 4648). When the last group has only 1 or 2 bytes, "=" pads the result to a multiple of 4. The URL-safe variant uses - and _ instead of + and /.

Worked examples

  • "Man"

    3 bytes → 4 characters: TWFu.

  • "Ma"

    2 bytes: one = fills the group, TWE=.

  • "é"

    2 bytes in UTF-8: w6k=.

Common mistakes

  • Using Base64 to protect a password.

    Anyone can decode it without a key: it is not encryption.

  • Thinking the size stays the same.

    30 bytes give 40 characters: a third more.

  • Putting standard Base64 in a URL: "??>" gives Pz8+, and the + turns into a space there.

    Use the URL-safe variant: Pz8-.

RFC 4648 test vectors

RFC 4648 test vectors
TextBase64
""""
"f""Zg=="
"fo""Zm8="
"foo""Zm9v"
"foob""Zm9vYg=="
"fooba""Zm9vYmE="
"foobar""Zm9vYmFy"

Size once encoded

Size once encoded
BytesCharacters
14
24
34
1016
100136
1,0001,336
1,000,0001,333,336

Frequently asked questions

Is Base64 a form of encryption?

No. Anyone can decode it, without a key: it only lets data travel safely as text (emails, JSON, URLs). Never use it to hide a password.

Why does my Base64 end with = or ==?

The length was not a multiple of 3 bytes: one = means the last group had 2 bytes, == means it had only 1.

Why is the encoded text longer?

Every 3 bytes become 4 characters, a third more, plus the padding. Accented letters and emoji take 2 to 4 bytes in UTF-8, so they grow even more.

Tech calculators

Tech calculators

Other calculators