Base64 Encoder
Convert plain text to Base64 or Base64URL, entirely client-side.
What is Base64 encoding?
Base64 converts arbitrary binary data into a subset of ASCII text using 64 printable characters. It exists because many transport formats (email, JSON, URLs, XML) were designed to safely carry text, not raw bytes. By re-representing binary as text, Base64 lets you embed images, keys, or file content anywhere a string is expected — most notably as the header and payload segments of a JWT.
How it works
The encoder groups input bytes into chunks of 3 (24 bits), then splits each chunk into four 6-bit groups. Each 6-bit value (0–63) maps to a character in the Base64 alphabet. If the input length isn't a multiple of 3, the output is padded with =. Toggle "Base64URL-safe" above to swap +/ for -_ and drop padding — the variant JWTs use.
Worked example
Encoding the text Hello, world! produces SGVsbG8sIHdvcmxkIQ==. Notice the two trailing = characters — 13 input bytes don't divide evenly into groups of 3, so two padding characters are added.
Common mistakes
- Assuming Base64 provides security — it is trivially reversible by anyone, with no key required.
- Forgetting to strip
+/and padding when the output must be used in a URL query string. - Double-encoding: running Base64 twice by mistake, producing garbled data when decoded once.
- Mixing up standard Base64 and Base64URL when hand-building a JWT segment.
Security notes
All encoding happens in your browser via btoa() and TextEncoder; no text is transmitted anywhere. Remember Base64 is an encoding, not encryption — never rely on it to hide secrets.
Code examples
const encoded = btoa("Hello, world!");
// "SGVsbG8sIHdvcmxkIQ=="import base64 print(base64.b64encode(b"Hello, world!"))
Base64 Encoder FAQ
What is Base64 encoding?
Base64 is a scheme for representing binary data as ASCII text, using 64 characters (A-Z, a-z, 0-9, + and /). It's commonly used to embed binary data (images, files, keys) inside text formats like JSON, URLs, or JWTs.
Is Base64 encryption?
No. Base64 is a reversible encoding, not encryption — anyone can decode it instantly with no key. Never use it to protect sensitive data; use it only to safely transport binary data as text.
What is Base64URL and how is it different?
Base64URL replaces the '+' and '/' characters with '-' and '_' and typically omits padding, making the output safe to use in URLs and JWT segments without additional escaping.
Why does my Base64 output end with '='?
The '=' characters are padding, added so the output length is a multiple of 4. Some contexts (like JWTs) strip this padding; standard Base64 usually keeps it.
Can I encode a file, not just text?
Yes — Base64 works on any binary data. This tool currently encodes text input from the browser; for files, use the FileReader API's readAsDataURL or a server-side utility.
Does encoding change the size of my data?
Yes, Base64 increases size by roughly 33%, since every 3 bytes of input become 4 characters of output.