Base64 is one of those terms that appears everywhere in computing and is explained almost nowhere. You see it in email attachments, in the long string after a JWT's first dot, in CSS files with image data pasted inline, and in API payloads where someone needed to ship a file through JSON. It looks like encryption, it behaves like a magic string, and it is neither. It is a translation layer between binary data and plain text, and once you understand the trade it makes, you will know exactly when to reach for it and when to leave it alone.
What Base64 Actually Does
Computers store files as bytes, and plenty of older or text-only systems cannot reliably carry arbitrary bytes. Base64 solves that by re-encoding binary data using only 64 characters that survive intact almost anywhere: A–Z, a–z, 0–9, plus + and /. The encoder takes every three bytes (24 bits), splits them into four 6-bit groups, and maps each group to one character. Three bytes in, four characters out. The word Man, for example, becomes TWFu. When the input does not divide evenly by three, equals signs pad the last group so the decoder knows how many bytes were real.
That is the entire mechanism. There is no key, no scrambling, no compression. Anyone with a decoder gets the original bytes back instantly. Base64 is a packaging format, not a lock — a distinction worth repeating, because people paste secrets into base64 and assume they are protected.
The 33 Percent Size Tax
Because four characters carry the payload of three bytes, base64 output is roughly 33 percent larger than the input; the ratio is exactly 4:3. A 1 MB file becomes about 1.37 MB. Email systems that wrap base64 at 76 characters per line add a little more, and every newline costs a byte.
That overhead is usually the deciding factor. Inline a small SVG icon or a 2 KB logo as a data URI and you save an HTTP request, which can genuinely help. Inline a 400 KB photograph and you have added more than 130 KB to a render-blocking HTML or CSS file, made the image impossible to cache separately, and forced the browser to decode it before it can finish parsing. The request you saved is often cheaper than the bytes you added. If you are weighing that trade for images specifically, our guide to embedding images as base64 data URIs walks through the numbers.
There is a CPU cost too, though it is modest on modern hardware. Encoding and decoding take work, and repeating it on large payloads in a hot path is waste. Base64 is cheap per call, not free at scale.
Where You Will Actually Meet It
Email attachments. MIME encodes binary files as base64 so they can travel through SMTP, a protocol that historically handled text only.
Data URIs. A string such as data:image/png;base64,... embeds a file directly inside HTML, CSS, or Markdown, removing a network request at the cost of a larger document.
JSON APIs. JSON has no byte type, so binary blobs, keys, and PDFs often arrive as base64 strings inside an ordinary field.
JSON Web Tokens. The header and payload of a JWT are base64url-encoded JSON, using - and _ instead of + and / and usually dropping padding. You can inspect one with our JWT decoder.
HTTP Basic authentication. The username and password are joined and encoded. That is an encoding step, not a security measure; TLS is what protects the credentials in transit.
Config systems. Kubernetes Secrets and similar tools store values base64-encoded. That makes binaries safe to embed in YAML, but anyone with read access can decode them in a second. Treat those values as readable configuration, not as protected data.
When to Use It — and When Not To
Use base64 when the channel is text-only, when you need to embed a small asset in a single document, when a JSON field must carry binary data, or when you need a copy-paste-safe representation of bytes in logs and test fixtures. It is also the conventional way to show a hash or signature as a short string.
Skip it when the goal is saving space, because it does the opposite. Skip it when you want confidentiality, because it offers none. Skip it for large files where streaming matters, for systems that accept raw bytes directly, and for data humans need to edit by hand. Also skip standard base64 in URL parameters unless you switch to the base64url alphabet; the + and / characters get mangled by query-string handling more often than you would expect.
+ with -, replace / with _, and strip the = padding. Standard base64 survives most copy-paste, but it breaks the moment it passes through a form, a router, or a query parser that treats + as a space.
A Clean Workflow With a Free Encoder
For quick jobs, skip the command-line round trip and use a browser tool that never uploads your data. Our free Base64 converter encodes and decodes text and files locally: paste a string to decode it, drop in a file to see its data URI, and copy the result. Because the work happens inside the page, it is reasonable for internal configs, test payloads, and the occasional certificate.
A few habits keep the results honest. Decode before you trust: if a string looks like base64 but produces garbage, it may be compressed, encrypted, or simply not base64 at all. Check padding and alphabet, since one stray space from a wrapped email line will break decoding. And verify the round trip by encoding, decoding, and comparing the output with the original. If you are validating the shape of a string rather than its value, a regex tester is often a faster sanity check than decoding by hand.
Base64 is boring infrastructure, and that is its virtue. It moves bytes through places that only speak text, at a known cost, with no surprises — as long as you remember that the cost is real.
Base64 FAQs
Is base64 encryption?
No. It is a reversible encoding with no key. Anyone can decode it, so never use it to protect passwords, tokens, or personal data. Use real encryption for confidentiality, and consult a security professional for anything sensitive.
Why does a base64 string end with = or ==?
Padding. Each = fills out the final four-character block when the input length is not a multiple of three. One = means two leftover bytes, two mean one leftover byte. Some formats, including the base64url used by JWTs, omit padding entirely.
Can I base64-encode a large video or archive?
You can, but you probably should not. The output is about a third larger and typically has to be held in memory, which makes it a poor fit for large files. Send the file directly or use a streaming or multipart upload instead.
Need to encode or decode something right now?
Open the Base64 Converter