Base64 encode & decode

Type or paste text to encode it as Base64, or switch to decode. Handles UTF-8 (emoji, accents) correctly and converts files to data: URIs.

File to data URI

Runs entirely in your browser. Nothing you paste is uploaded.

How Base64 works

Base64 takes the input bytes three at a time (24 bits) and splits them into four 6-bit groups. Each group indexes the alphabet A–Z a–z 0–9 + /. If the input length is not a multiple of three, = padding fills the last block. The output is always about 4/3 the size of the input.

encoded length = 4 × ⌈bytes ÷ 3⌉

Worked example

"Man" is the bytes 77, 97, 110 → binary 01001101 01100001 01101110 → groups 19, 22, 5, 46 → TWFu.

TextBase64Note
MTQ==1 byte → 2 padding chars
MaTWE=2 bytes → 1 padding char
ManTWFu3 bytes → no padding
éw6k=UTF-8 uses 2 bytes for é

Base64 vs base64url

The URL-safe variant (RFC 4648 §5) replaces + with - and / with _, and usually drops padding. JWTs use base64url. The decoder here accepts both.

Base64 is not encryption

Anyone can decode Base64. Use it to move binary data through text-only channels (email, JSON, HTML), never to hide secrets.

Frequently asked questions

Why does my decoded text show strange characters?
The original was probably not UTF-8 text but binary data (an image, a zip) or text in another encoding.
How much bigger does Base64 make data?
About 33%: every 3 bytes become 4 characters, plus up to 2 padding characters.
What is a data URI?
A URL of the form data:image/png;base64,… that embeds the file itself, so small icons can be placed directly in HTML or CSS.