Guide
How Base64 encoding works
By Logappradeep · ServiceNow developer
Base64 is a way to represent arbitrary bytes using only 64 printable ASCII characters: A–Z, a–z, 0–9, +, and /. It exists because many systems, including email, JSON, XML, HTTP headers, and URLs, were designed for text and can corrupt or reject raw binary data. Base64 lets binary content travel safely through those text-only channels.
The mechanics, per RFC 4648
The encoder reads the input three bytes (24 bits) at a time and splits those bits into four groups of six. Each 6-bit value, from 0 to 63, indexes one character of the alphabet. Take the word Man:
M a n
01001101 01100001 01101110
010011 010110 000101 101110
T W F u → TWFu
When the input length is not a multiple of three, the final group is padded with = characters, so hello (five bytes) becomes aGVsbG8=. Because every three bytes become four characters, Base64 output is about 33% larger than the original.
Text and UTF-8
Base64 encodes bytes, not characters, so text must first be converted to bytes. This tool uses UTF-8, the encoding the web runs on, which means é (two bytes, C3 A9) encodes to w6k=, and emoji and non-Latin scripts work as expected. JavaScript's built-in btoa() function, by contrast, throws an error on any character above U+00FF unless you convert the text to UTF-8 bytes yourself, a frequent source of confusion.
Where you meet Base64
- Data URIs that inline small images or fonts in HTML and CSS, such as
data:image/png;base64,.... - Email attachments, encoded with MIME Base64, which wraps lines at 76 characters.
- HTTP Basic authentication, where
user:passwordis Base64-encoded in the Authorization header. - Kubernetes Secrets, whose values are stored as Base64 strings.
- Binary fields in JSON APIs, such as file uploads, signatures, and keys.
Pitfalls
- Base64 is not encryption. It has no key and anyone can reverse it instantly. A Base64-encoded password in a config file or a Kubernetes Secret is effectively plain text to anyone who can read it.
- Base64URL is a different alphabet. JWTs and many URL parameters use
-and_instead of+and/, usually without padding. Many standard decoders reject such strings; this decoder accepts both alphabets, and the URL-safe output switch produces Base64URL when encoding. - Whitespace and line breaks. MIME-wrapped Base64 contains newlines; strict decoders may need them removed, while this one ignores whitespace.
- Size bloat. Inlining large files as data URIs increases page weight and prevents separate caching.
Encoding and decoding happen live in your browser as you type; nothing is uploaded, so it is safe to inspect tokens and credentials.