Choose language

Base64 Encode

Convert text or data into a Base64 string instantly. Handles UTF-8 input, copy the result with one click, and works fully in your browser.

Mehmet Demiray Published Updated
Share
Use - and _ and drop the = padding for URLs
Insert a line break every 76 characters

What Base64 Encoding Does

Base64 encoding takes binary or text data and represents it using a set of 64 printable characters: A-Z, a-z, 0-9, plus + and /. The goal is not secrecy or compression, it is safe transport. Many systems were built to handle text reliably but mangle raw binary bytes, so encoding turns any input into a plain ASCII string that survives email headers, JSON fields, and URLs.

The process groups your input into chunks of 3 bytes (24 bits) and splits each chunk into four 6-bit values, mapping every value to one Base64 character. When the input length is not a multiple of three, padding with = keeps the output aligned.

For example, the word Hi becomes SGk=. The encoded string is always larger than the original by roughly 33%, which is the trade-off for guaranteed safe transport across text channels. To reverse the process, use Base64 Decode.

Encoding Text Versus Binary Data

Base64 works on bytes, so the first step is always converting your input into bytes. With plain text, this tool reads characters as UTF-8, meaning accented letters and emoji each expand into multiple bytes before encoding. That is why a short string with non-ASCII characters can produce a longer Base64 output than you might expect.

The table below shows how different inputs map to their encoded form:

Input Bytes Base64 output
A 1 QQ==
Cat 3 Q2F0
Café 5 Q2Fmw6k=

Notice that Café is four characters but five bytes, because é takes two bytes in UTF-8. Binary data such as images or files follows the same rule: every byte is encoded directly, with no concept of characters at all. If you want to encode an actual file rather than typed text, use File to Base64 instead, which reads the file contents byte by byte. The encoding logic is identical either way, so the only real difference is how the input bytes are gathered before the conversion begins.

Reading Padding and Output Length

The = characters at the end of a Base64 string are padding, not data. They appear because encoding works in groups of three input bytes, and when the final group is incomplete the output is padded to keep a clean four-character block.

The rule is simple:

  • Input length divisible by 3: no padding
  • One byte left over: two = signs
  • Two bytes left over: one = sign

You can estimate output size before encoding. For an input of n bytes, the encoded length is 4 * ceil(n / 3) characters. So 10 bytes produce 16 characters, and 100 bytes produce 136 characters.

Knowing this helps when a field has a length limit, such as a database column or a URL parameter. If the encoded value lands in a web address, remember that + and / are not URL-safe and may need additional handling with URL Encode. Padding also lets a decoder know exactly where the data ends, which is why stripping the = signs can cause a strict decoder to reject an otherwise valid string.

Common Places You See Base64

Base64 shows up across the stack once you know what to look for. Email attachments use it through the MIME standard, which is why a raw email source is full of long character blocks. Data URIs embed small images directly in HTML or CSS with a prefix like data:image/png;base64, followed by the encoded bytes.

Web tokens lean on it heavily. A JSON Web Token is three Base64 segments joined by dots, and HTTP Basic Authentication sends credentials as a single encoded string. APIs often accept binary payloads, such as a file upload inside a JSON body, by encoding them first.

Keep in mind that Base64 is encoding, not encryption. Anyone can decode it instantly, so it never protects secrets on its own. It simply makes binary data safe to move through text-only channels. When you need to turn an encoded value back into readable form, Base64 Decode handles the reverse step.

Encoding Safely Without Surprises

A few habits prevent the most common Base64 mistakes. First, confirm the character encoding of your source text. This tool uses UTF-8, which is the modern default, but if your data came from a legacy system using a different encoding, the bytes will differ and so will the result.

Second, watch for hidden whitespace. A trailing newline or stray space in your input becomes part of the encoded bytes, so hello and hello produce different strings. Trim your input when an exact match matters.

Third, decide whether you need standard or URL-safe Base64. Standard output uses + and /, while URL-safe variants swap them for - and _. If the value will travel inside a query string, the safer path is often to encode normally and then apply URL Encode to the surrounding URL.

Because this tool runs entirely in your browser, the text you paste never leaves your device, which matters when the input includes sensitive content.

The ones we answer the most.

Is Base64 a form of encryption?

No. Base64 is reversible encoding, not encryption. Anyone with the encoded string can decode it back to the original in seconds, with no key required. It only makes binary data safe to send through text channels. If you need to protect secrets, use real encryption and treat Base64 purely as a transport format.

Why is my encoded string longer than the original?

Base64 represents every 3 bytes of input as 4 output characters, so the encoded result grows by about 33%. Padding with = can add a character or two as well. This size increase is expected and is the cost of making data safe for text-only systems.

What do the equals signs at the end mean?

They are padding. Base64 processes input in groups of three bytes, and when the last group has only one or two bytes, the output is padded with = to complete a four-character block. One leftover byte gives == and two leftover bytes give a single =.

Does this tool handle emoji and accented characters?

Yes. The encoder reads your text as UTF-8, so characters like é, ñ, and emoji are converted to their byte sequences before encoding. These characters take more than one byte each, which is why such input can produce a longer Base64 string than its character count suggests.

Can I encode an image or file here?

This page is built for text and pasted data. To encode an actual file such as an image or PDF, use File to Base64, which reads the file's raw bytes and returns a Base64 string you can embed or transfer.

How do I get the original text back?

Run the encoded string through Base64 Decode. As long as the string is valid Base64 and was encoded as UTF-8 text, decoding returns your exact original input, including any spaces or special characters that were part of it.