Base64

Encode and decode Base64 with correct UTF-8 handling, plus a file-to-Data-URI converter that reports the real size cost.

Base64EncodingFiles

Text

Output

          

Waiting for input.

File → Base64 / Data URI

The file is read with the FileReader API and encoded in this tab. It is never uploaded.

Data URI

        
File size
—
Encoded size
—
Overhead
—
MIME type
—

About this Base64 encoder

Base64 maps every three bytes of input onto four characters drawn from a 64-symbol alphabet. Because four characters carry the information of three bytes, the encoded text is about 33% larger than the original — a 3 MB image becomes roughly 4 MB of text. That expansion is the price of moving binary data through channels that only accept printable ASCII, such as JSON, XML or an email header.

The classic failure of naive Base64 tools is non-ASCII text. The browser's btoa() function only accepts characters in the Latin-1 range, so calling it directly on Chinese, Cyrillic or emoji produces either an exception or mojibake. This page encodes your string to UTF-8 bytes first and then Base64-encodes those bytes, and reverses that order on decode, so multi-byte text survives the round trip intact.

Base64URL is a variant used by JWTs and OAuth, defined in RFC 4648 §5. It substitutes - for + and _ for / so the result is safe inside a URL path, and it usually drops the = padding. Decoding here accepts either alphabet, so you can paste a token segment without adjusting it first. Remember that Base64 is an encoding, not encryption: it provides no confidentiality whatsoever.

Related tools

Found a bug, or need a tool that is not here? Email 2273917172@qq.com — a human reads every message.