Toolnova
DeveloperTutorial

Base64 Encoding Explained: What It Is and Why Developers Use It

Base64 appears in JWT tokens, data URIs, email attachments, and API payloads. Learn exactly what it does, what it does not do, and how to encode and decode it free.

TNToolnova Team2 min read

Base64 looks like random garbage: SGVsbG8sIHdvcmxkIQ==. But it encodes the text "Hello, world!" — and understanding why that matters will make a lot of developer output suddenly readable.

What Base64 is

Base64 is an encoding scheme that converts binary data into a string of 64 printable ASCII characters (A–Z, a–z, 0–9, +, /).

The key word is encoding, not encryption. Base64 does not provide any security — anyone can decode it instantly. It is a way to represent binary data safely in contexts that only handle text.

Why it exists

Many protocols were designed to handle plain ASCII text:

  • Email (SMTP) — originally only handled 7-bit ASCII. Sending a binary file (an image, a PDF) required encoding it as text first. This is still how email attachments work under the hood.
  • HTTP headers — certain characters have special meaning in headers. Base64 avoids collisions.
  • JSON and XML — these formats are text; you cannot embed raw binary bytes. Base64 lets you embed images or files as a string field.
  • Data URIs — images embedded directly in HTML or CSS use Base64: <img src="data:image/png;base64,iVBOR...">.

How it works (briefly)

Base64 groups the binary data into chunks of 6 bits and maps each chunk to one of 64 characters. Three bytes of binary input become four Base64 characters. This expansion is why Base64-encoded data is roughly 33% larger than the original.

The trailing == or = is padding — it indicates how many bytes were added to complete the final group.

Encoding and decoding

The Base64 Encode / Decode tool converts in both directions:

  • Encoding: paste any text or paste a data URI, get the Base64 string.
  • Decoding: paste a Base64 string, get the original text back.

For images specifically, the Image to Base64 tool converts any image file into a Base64 data URI, and Base64 to Image reverses the process.

Common uses in practice

  • JWT tokens — a JSON Web Token is three Base64-URL-encoded sections separated by dots. Decode the middle section to read the payload claims.
  • Basic authentication — HTTP Basic Auth sends username:password encoded in Base64 in the Authorization header. This is why it is completely insecure without HTTPS.
  • Inline images in CSS — small icons can be embedded directly as url("data:image/svg+xml;base64,...") to save an HTTP request.
  • API payloads — APIs that accept file uploads often expect the file as a Base64 string in a JSON body.

Base64 is not a security measure. If you need to protect data, use encryption. If you need to represent binary data as text, use Base64.

Explore 285+ free tools

No signup, no watermarks — everything runs privately in your browser.

Browse all tools

Keep reading