NV ToolkitFormat · Validate · Convert
Guide

What is Base64? Encoding Explained Without the Mystique

Base64 turns any bytes into safe, printable text — that's all it does, and it does it everywhere: JWTs, email attachments, data URIs, Kubernetes secrets. Here's how it works and the one thing it absolutely is not.

In short

Base64 is a text encoding that represents any binary data using 64 printable characters (A–Z, a–z, 0–9, +, /), so bytes can safely travel through text-only channels like JSON, URLs, and email. It works by regrouping every 3 input bytes into four 6-bit chunks, padding the final group with = when needed. It is reversible by anyone and provides zero confidentiality — encoding, not encryption.

By NaveenKumar T · Software engineer · builds and maintains NV Toolkit Published 2026-06-04 2 min read

The problem it solves

Many channels only transport text reliably: JSON strings, URLs, XML, email headers, environment variables. Binary data — images, encrypted blobs, arbitrary bytes — breaks them. Base64 is the bridge: it re-expresses any byte sequence using 64 safe characters (A–Z, a–z, 0–9, +, /), so binary can ride through text-only channels untouched.

How the encoding actually works

Bytes are 8 bits; Base64 characters carry 6. The algorithm takes 3 bytes (24 bits), splits them into four 6-bit chunks, and maps each chunk to one of the 64 characters. When the input isn't a multiple of 3 bytes, = padding fills the final group — that's the whole mystery of the trailing equals signs. The cost is fixed: output is ~33% larger than input, always.

javascript
// "Hi!" → bytes 72,105,33 → 24 bits → four 6-bit values → "SGkh"
btoa("Hi!")            // "SGkh"
atob("SGkh")           // "Hi!"
// 4 input bytes? Last group pads: btoa("Hi!!") → "SGkhIQ==" (note the ==)

Where you meet it daily

JWTs are three Base64url sections joined by dots — decode the middle one and the claims are right there. Data URIs embed images in CSS/HTML (data:image/png;base64,…). Kubernetes Secrets Base64-wrap values so arbitrary bytes survive YAML. Email attachments have shipped as Base64 since MIME. Basic auth headers are Base64 of user:password. In each case it's the same trick: bytes that must pretend to be text.

Note the URL-safe variant: standard + and / break URLs, so Base64url substitutes - and _ (and usually drops padding). JWTs use it; if a decoder rejects your string, swapping those characters back is often the fix.

WhereWhat's Base64-encodedWhy
JWTsHeader and payload JSONSafe to place in URLs/headers, dot-separated
Data URIsImage or font bytesEmbed binary assets directly in CSS/HTML
Kubernetes SecretsArbitrary secret bytesYAML/JSON can only hold text
Email attachments (MIME)File bytesSMTP historically only carried text
HTTP Basic Authuser:passwordHeader values must be text

What Base64 is NOT: security

Base64 is encoding, not encryption — there is no key, and decoding requires nothing but the alphabet. Anyone can reverse it instantly (our decoder does). 'The password is Base64-encoded' means the password is plaintext with extra steps. Treat Base64 values as readable by anyone who can see them; if secrecy matters, encrypt first, then Base64 the ciphertext for transport.

How this was tested: The Base64 examples (btoa/atob) were run with Node 22 on 2026-09-10.

Sources

  1. RFC 4648 — The Base16, Base32, and Base64 Data Encodings
  2. MDN — Base64 (Glossary)
  3. MDN — Window.btoa()

Frequently asked questions

Is Base64 encryption?

No. Encryption requires a secret key; Base64 has none — it's a public, reversible alphabet mapping. It provides transport safety, zero confidentiality. Anything 'protected' with Base64 is effectively plaintext.

Why does my Base64 string end with = or ==?

Padding. Output groups represent 3 input bytes; when the input length isn't divisible by 3, = fills the remainder — one = for two leftover bytes, == for one. Decoders use it to know exactly where the data ends.

Can I decode a JWT with a Base64 tool?

Yes — split on the dots and decode the first two sections (header and payload); they're Base64url-encoded JSON. Our Base64 to JSON tool decodes and pretty-prints them in one step. The third section is a binary signature: verifiable, not meaningfully 'readable'.

Paste any Base64 — a JWT payload, a K8s secret, an API blob — into Base64 to JSON and read it instantly, fully client-side.

Decode something

Keep working

Related tools