← Back to all posts

What is Base64? Why does it show up in data transfer?

Base64 turns binary into printable characters — JWTs, email attachments and data URLs all rely on it.

The scenario

You spot a long run of printable characters in a JWT, an API field or a log — it is very often Base64 (or Base64URL).

What Base64 is

Every 3 bytes become 4 characters, so the payload grows by roughly 33%, and in exchange binary data can travel over a text channel.

How to use it

For text encoding and decoding, use the Base64 tool.

const encoded = btoa(String.fromCharCode(...new TextEncoder().encode('hello')))
import base64
base64.b64encode(b'hello').decode()

The trade-offs

The upside is that it is channel-friendly; the downside is that it is not encryption, and it makes the payload bigger.

Wrapping up

Use Base64 for transport encoding; use real encryption or a signature to protect secrets.