Base64 Encode/Decode

Encode text or files to Base64 and decode it back - fully Unicode-safe, with a URL-safe option. Everything runs in your browser.


Encode a file to a data URI

Choose a file or drop it here
Any file type. It is read locally and never uploaded.

How Base64 encoding works

Base64 takes three bytes of data at a time - that is 24 bits - and splits them into four 6-bit groups. Each group indexes into a 64-character alphabet (A-Z, a-z, 0-9, plus + and /), producing four printable characters. When the input length is not a multiple of three, one or two = characters pad the end. The result is safe to move through systems that only understand plain text.

Unicode done right

The browser's built-in btoa() only handles Latin-1 bytes, so it throws on anything like an emoji or an accented letter. This tool instead runs your text through a TextEncoder to get proper UTF-8 bytes before encoding, and a TextDecoder on the way back. That means cafe with an accent, a Chinese character or a rocket emoji all encode and decode losslessly.

Data URIs from files

Drop a file into the box and you get a data: URI: the file's MIME type, the base64 marker, then the encoded bytes. Paste that straight into an <img src>, a CSS background-image or a stylesheet to embed a small icon without a separate network request. Keep it to small assets - the 33% size overhead makes it a poor fit for large images. For those, use the dedicated image to Base64 tool with its ready-made HTML and CSS snippets.

Related developer tools: the URL encoder for query-string safety, the JWT decoder (JWTs are three Base64url segments), and the hash generator when you need a one-way transform rather than a reversible one.

Frequently asked questions

What is Base64 used for?
Base64 turns any binary or text data into a string of 64 safe ASCII characters (A-Z, a-z, 0-9, + and /). It lets you embed images in CSS or HTML as data URIs, send binary data through text-only channels like email or JSON, and store small files inline. It is an encoding, not encryption - it provides no security.
Does Base64 support emoji and non-English text?
Yes. This tool encodes text as UTF-8 first, so emoji, accents and any Unicode character round-trip correctly. Older tools that use raw btoa() break on these characters - this one does not.
What is URL-safe Base64?
Standard Base64 uses + and / which have special meaning in URLs, and = padding which must be escaped. URL-safe Base64 swaps + for - and / for _ and drops the padding, so the result can be dropped straight into a URL or filename. JSON Web Tokens use this variant.
Is Base64 encryption?
No. Anyone can decode Base64 instantly - it hides nothing. Never use it to protect passwords or secrets. Use it only to transport or embed data safely. For a genuine one-way transform use a hash generator instead.
Why is Base64 bigger than the original?
Base64 represents every 3 bytes of input as 4 characters, so the encoded output is about 33% larger than the source. That overhead is the price of making binary data survive text-only transport.