Base64 Encode

Turn text or a file into Base64. UTF-8 correct, with URL-safe and MIME line-wrapping options.

runs in your browserno uploadno sign-up

Base64

Base64 appears here as you type.

How 3 bytes become 4 characters

Base64 reads your data 24 bits at a time — three 8-bit bytes — and re-slices those bits into four 6-bit numbers. Each number from 0 to 63 picks one character from the alphabet. Type something short and watch the regrouping; try one and two characters to see where the = padding comes from, and an accented letter to see UTF-8 at work.

bytes
480100100069011010012100100001
6-bit → char
01001018S0001106G10010036k10000133h

Hi! → SGkh

* When the last group is short, zero bits fill out the final 6-bit number, and = marks each missing byte so the length stays a multiple of 4.

What Base64 is for

Base64 (defined in RFC 4648) writes arbitrary bytes using only 64 safe ASCII characters, so binary data can travel through systems built for text: email attachments (MIME), data: URIs in HTML and CSS, JSON fields, HTTP Basic auth headers and JWTs.

The cost is size: every 3 bytes become 4 characters, a 33% increase, plus up to two = padding characters at the end. The explainer below shows exactly how the bits are regrouped.

Variants

URL-safe Base64 replaces + with - and / with _ and usually drops the padding, so the result can sit in a URL or filename unchanged (JWTs use it). MIME wrapping breaks the output into 76-character lines as email requires (RFC 2045).

Frequently asked questions

Why does Base64 end with = or ==?

Input is processed 3 bytes at a time. If the last group has only 1 or 2 bytes, the output is padded with == or = so its length is a multiple of 4.

Why does the same text give a different result elsewhere?

Usually because of character encoding. This tool encodes text as UTF-8 (so é is two bytes, C3 A9). Some tools use Latin-1 or UTF-16, which produce different bytes and therefore different Base64. Trailing newlines also change the result.

How much bigger does Base64 make data?

About 33%: output length is 4 × ceil(n / 3) characters for n bytes. MIME line breaks add roughly 2.6% more.

Can I encode a file?

Yes. Choose a file and it is read locally and encoded in your browser; for images, the Image to Base64 tool also builds a ready data URI and CSS snippet.