Skip to content
AgileLogics

Base64 Encoder

Converts UTF-8 text into its Base64 representation, entirely in your browser.

How it works

Type or paste text into the input panel and click Encode.

What is Base64 encoding?

Base64 encoding converts bytes into a string made from 64 safe characters: A–Z, a–z, 0–9, + and /, with = for padding. It lets you put text or binary data into places that only accept plain ASCII, such as email bodies, JSON fields, data URLs and HTTP headers, without characters getting mangled.

The scheme is defined in RFC 4648. This tool encodes text using the standard alphabet from section 4 of that RFC.

How to encode text to Base64

  1. Type or paste your text into the input box.
  2. Click Encode.
  3. Copy the Base64 string from the output panel.

Spaces and line breaks in your input are encoded like any other character, so line1 and line2 on separate lines produce bGluZTEKbGluZTI=, where the newline is part of the data.

How it works, step by step

Base64 reads the input three bytes (24 bits) at a time and splits them into four 6-bit groups. Each 6-bit number, from 0 to 63, picks one character from the alphabet.

Take the text Hi!:

Step Value
Characters H, i, !
Bytes in binary 01001000 01101001 00100001
Regrouped as 6 bits 010010 000110 100100 100001
As numbers 18, 6, 36, 33
Base64 characters S, G, k, h

So Hi! encodes to SGkh. When the input isn't a multiple of three bytes, the encoder pads: Man gives TWFu, Ma gives TWE=, and M gives TQ==.

Because 3 bytes become 4 characters, Base64 output is about a third larger than the input. Hello, World! is 13 bytes and encodes to the 20-character SGVsbG8sIFdvcmxkIQ==.

UTF-8 and non-Latin text

The browser's built-in btoa() only accepts characters in the Latin-1 range and throws an error on anything else. This tool converts your text to UTF-8 bytes first, so every character works:

Input UTF-8 bytes Base64
café 5 Y2Fmw6k=
👍 4 8J+RjQ==
user:pass 9 dXNlcjpwYXNz

UTF-8 is what almost every other system expects, so output from this tool decodes correctly in Python, PHP, Java or the command line. A different encoder that used Latin-1 would turn café into Y2Fm6Q== instead, which is why the same text can give different Base64 in different tools.

Where Base64 is used

  • HTTP Basic authentication. The header is Authorization: Basic followed by Base64 of username:password (RFC 7617). That's encoding, not protection, so Basic auth is only safe over HTTPS.
  • Data URLs that embed small files in HTML or CSS. For pictures, use the image to Base64 converter, since this tool encodes text only.
  • Email attachments, which MIME transfers as Base64.
  • JSON and XML fields that need to carry binary data.

What this tool doesn't do

  • It doesn't encode files. Paste text only.
  • It doesn't produce URL-safe Base64 (- and _ instead of + and /, from RFC 4648 section 5). If the result goes into a URL, either convert those characters yourself or run the output through the URL encoder.
  • It doesn't wrap lines at 76 characters the way MIME email does. The output is one continuous line.
  • It doesn't encrypt anything. If you need to verify data without revealing it, a hash generator is the right tool.

To turn Base64 back into text, use the Base64 decoder.

Last updated

Frequently asked questions

Does it support emoji and non-English characters?
Yes. Text is converted to UTF-8 bytes before encoding, so "café" becomes Y2Fmw6k= and a thumbs-up emoji becomes 8J+RjQ==. Encoders that skip this step fail on any character outside Latin-1.
Is Base64 encryption?
No. Base64 is a reversible encoding with no key, so anyone can decode it in a second. Never use it to hide passwords or secrets. Use real encryption for that, or a hash if you only need to compare values.
Why does my output end with = or ==?
Base64 turns every 3 bytes into 4 characters. When the input length isn't a multiple of 3, the last group is padded with one or two = signs so the output length is always a multiple of 4.
Does it produce URL-safe Base64?
No, it produces the standard alphabet with + and / and = padding (RFC 4648 section 4). For the URL-safe variant, replace + with -, / with _, and usually drop the trailing = signs.
Is my text sent to a server?
No. Encoding uses the browser's built-in btoa function, so the text you type stays on your device.