Skip to content
K Knidox Search…
Computer Science · Encoding

Base64 Encode & Decode

Convert text to Base64 and back — UTF-8 safe, so accents and emoji survive the round trip.

Direction
5 chars
Base64 output
SGVsbG8=

Base64 turns any text or data into a 64-character ASCII set so it travels safely through systems that only handle plain text. Encoding “Hello” gives SGVsbG8=. To decode, paste SGVsbG8= and switch to Decode to get “Hello” back. It is reversible encoding, not encryption — anyone can decode it.

What Base64 is

Base64 is a way of writing arbitrary bytes using only 64 printable ASCII characters — the letters A–Z and a–z, the digits 0–9, plus “+” and “/”. Because those characters survive email, URLs, JSON, and other text-only channels untouched, Base64 is the standard way to embed binary data (images, keys, attachments) inside text formats. It does not hide or protect the data; it only repackages it.

3 bytes = 24 bits = 4 × 6-bit Base64 characters

Every 3 input bytes map to exactly 4 output characters.

How the mapping works

Base64 reads the input three bytes at a time. Three bytes are 24 bits, and 24 splits evenly into four 6-bit groups. Each 6-bit group is a number from 0 to 63, which selects one character from the Base64 alphabet. When the input does not divide neatly by three, the final group is padded with zero bits and the output is padded with one or two “=” characters so the length stays a multiple of four.

  1. 1
    Choose Encode. The Encode segment reads your text and produces Base64.
  2. 2
    Type or paste your text. Enter Hi. Its UTF-8 bytes are H = 72 and i = 105.
  3. 3
    Group the bits into sixes. The 16 bits 01001000 01101001 are padded and regrouped into 010010 000110 100100.
  4. 4
    Map each group to a character. The values 18, 6, and 36 become S, G, and k from the Base64 alphabet.
  5. 5
    Add padding. Two bytes fill only three of four output slots, so one “=” is appended: Hi → SGk=.

The Base64 alphabet

Each 6-bit value (0–63) maps to one character; “=” is padding, not a value.

Index rangeCharactersNotes
0–25A–ZUppercase letters, A = 0
26–51a–zLowercase letters, a = 26
52–610–9Digits, 0 = 52
62+Plus sign
63/Forward slash
(none)=Padding to keep length a multiple of 4

Encoding is not encryption

Base64 offers no security at all — there is no key, and the transformation is public, so anyone can decode it instantly. Never use it to protect passwords or private data; for that you need real encryption. Be aware too that Base64 inflates size by roughly 33%, because every 3 bytes of input become 4 characters of output. That overhead is the price of making binary data safe to paste into text-only places.

Is Base64 a form of encryption?
No. Base64 is reversible encoding with no key — the rules are public, so anyone can decode it in seconds. Use it to transport data through text-only channels, never to keep a secret.
Why does “Hello” become SGVsbG8=?
The five bytes of “Hello” are split into 6-bit groups and mapped to the Base64 alphabet. Five bytes do not divide evenly by three, so one “=” pads the final group, giving SGVsbG8=.
What does the “=” at the end mean?
It is padding. Base64 output length is always a multiple of four, so when the input is not a multiple of three bytes, one or two “=” characters fill the gap. They carry no data.
Why is Base64 about 33% larger than the original?
Every 3 bytes (24 bits) become 4 characters that each carry only 6 bits of data. That 4-for-3 ratio adds roughly one third to the size, plus a little for padding.
Does this handle accents and emoji correctly?
Yes. The tool encodes your text as UTF-8 bytes first, so characters like é or ☕ round-trip safely. Plain atob/btoa alone would mangle them, but the UTF-8 step prevents that.
Why do I get a “Not valid Base64” message?
Decoding fails when the input contains characters outside the alphabet (A–Z, a–z, 0–9, +, /, =) or has the wrong padding. Check for stray spaces, line breaks, or a truncated string.