Skip to main content

Developer

What is Base64 and when should you use it?

A clear explanation of Base64 encoding, what it is for, and why it is not encryption.

Published 2026-10-11

The problem it solves

Many systems, such as email and JSON, are designed for plain text and can break or corrupt raw binary data. Base64 represents any bytes using just 64 safe characters: A–Z, a–z, 0–9, + and /.

Three bytes (24 bits) are split into four 6-bit groups, each mapped to one character. Padding with = fills the end when the input length is not a multiple of three.

Common uses

Base64 appears in data URLs for small images, email attachments, HTTP basic authentication headers and the segments of JSON Web Tokens. A URL-safe variant uses - and _ instead of + and /.

Because it turns 3 bytes into 4 characters, the output is about 33% larger than the input.

It is not encryption

Anyone can decode Base64 instantly, so it provides no secrecy. Never use it to hide passwords, API keys or personal data.

If you need to protect information, use real encryption. Use Base64 only to transport data safely through text-based systems.

Encoding text with Unicode

Browsers' built-in btoa function fails on characters outside Latin-1, such as emoji. The reliable approach is to convert the text to UTF-8 bytes first and then encode those bytes.

Our Base64 tool does this for you and decodes back to the original text in the same way.