Pixel and Prose

Base64 Encode and Decode: text and files

Updated
Cover image for "Base64 Encode and Decode: text and files" – Pixel and Prose

Encode text to Base64 or decode Base64 back to text, with full support for accents, emoji and other UTF-8 characters. You can also turn a small file or image into a Base64 string or data URL.

File to Base64

Encoding and decoding run in your browser. Nothing you paste or choose is uploaded.

Base64 tool encoding the text Hello, café! into SGVsbG8sIGNhZsOpIQ==

What is Base64?

Base64 writes any data, including images and binary files, using only 64 safe characters: A to Z, a to z, 0 to 9, plus + and /, with = as padding. Systems that only handle plain text, such as email, JSON and URLs, can then carry the data without corrupting it.

The cost is size: every 3 bytes become 4 characters, so Base64 is about 33% larger than the original.

Base64 is not encryption. Anyone can decode it in a second, so a password or personal detail written in Base64 is as readable as plain text to anyone who sees it.

To share a link as a scannable image instead, use the QR code generator. To keep a data URL short, compress the image before you encode it.

Old typewriter keys close up, with text saying Base64 is about 33 percent larger and not encryption

Frequently asked questions

Why does my decoded text look garbled?

The original data was probably not text, for example an image or a compressed file, or it was text in an encoding other than UTF-8. This tool decodes to UTF-8 text and tells you when the bytes are not valid UTF-8.

What is URL-safe Base64?

A variant used in web addresses and tokens such as JWTs. It replaces + with - and / with _, and usually drops the = padding. The decoder here accepts both forms automatically.

What is a data URL?

A data URL puts a file directly inside a web page or stylesheet, in the form data:image/png;base64,.... It is handy for small icons, but a large file inside a page adds about a third to its size and the browser cannot cache it separately, so the page loads slower than with a normal image link.

Does it handle emoji and accents?

Yes. Text is converted to UTF-8 bytes before encoding, so "café" and emoji encode the same way as in most programming languages.