encoding
base64

Mastering Base64 Encoding (and When Not to Use It)

Base64 is everywhere — data URIs, JWTs, email. Learn how it works, why it is not encryption, and how to handle Unicode correctly.

DevTools HubApril 28, 20265 min read

What Base64 actually does

Base64 represents binary data using 64 printable ASCII characters. It exists so that binary content can travel safely through systems designed for text — URLs, JSON fields, email headers and HTML attributes.

It is encoding, not encryption

A crucial point: Base64 is fully reversible and offers no security whatsoever. Anyone can decode it instantly with the Base64 Decode tool. Never use it to hide secrets.

Handling Unicode

Naive Base64 of Unicode text often breaks because the browser's btoa only handles Latin-1. The correct approach encodes text to UTF-8 bytes first. Our Base64 Encode tool does this automatically, so emoji and accented characters round-trip correctly.

Practical uses

  • Embedding small images as data URIs
  • Encoding credentials for HTTP Basic Auth
  • Transporting binary blobs inside JSON

Conclusion

Base64 is a transport encoding, not a security measure. Use it to move data safely through text channels — and reach for real cryptography when you need protection.

Related posts