โœฆ Developer Tool ยท Interactive
โ† Back to dev

Base64 Encoder and Decoder

Encode text to Base64 or decode Base64 strings back to readable text. Learn how padding works, why output grows by 33% and why Base64 is not encryption.

{ } Developer Toolโšก Instant result
</>
{ } 01 ยท DEVELOP

What Base64 encoding does to your data

Base64 turns any data, text or binary, into a string of 64 safe characters. These are A-Z, a-z, 0-9, plus + and /. It exists because many systems were designed for plain text. Email bodies, JSON fields and URLs can corrupt raw bytes, but they carry Base64 text without trouble.

This Base64 encoder and decoder works both ways. Encode plain text into Base64, or paste an encoded string to recover the original.

How three bytes become four characters

The encoder reads input in groups of 3 bytes, which is 24 bits. It splits those bits into four 6-bit chunks. Each chunk maps to one character in the Base64 alphabet.

Input textBytesBase64 output
Man3TWFu
Hi2SGk=
A1QQ==

The = signs are padding. They appear when the input length is not a multiple of 3. One = means two bytes were in the last group. Two means only one byte was left. Some systems strip padding entirely. Most decoders cope, or you can add = until the length divides by four.

The size trade-off

Because 3 bytes become 4 characters, encoded data is about 33% larger. A 300 KB image turns into roughly 400 KB of Base64 text. That is fine for small icons, but wasteful for large photos.

Base64 is not encryption

Anyone can decode Base64 in seconds, with no key. It hides nothing. HTTP Basic Auth headers, for example, carry the username and password only Base64-encoded. That is why such headers must always travel over HTTPS.

If you need to protect data, use real encryption such as AES, or hashing for passwords. Use Base64 only to move bytes safely through text-only channels. A quick test makes the point: paste a "hidden" value into any decoder, and plain text appears instantly.

Encoding Base64 in code

In JavaScript, btoa() encodes and atob() decodes, but both fail on characters outside Latin-1. Python's base64.b64encode() works on bytes, so call .encode("utf-8") on a string first. On Linux and macOS, the base64 command handles files from the terminal.

Where developers run into Base64

  • Data URIs: embedding a small SVG or PNG in CSS as data:image/png;base64,...
  • Email attachments: MIME encodes files in Base64 inside the message body.
  • JWT tokens: the header and payload use Base64URL, a variant that swaps + and / for - and _.
  • API payloads: sending file contents inside a JSON field.
  • Kubernetes secrets: values in secret manifests are stored Base64-encoded.

If decoding returns garbled symbols, the source was probably binary, such as an image, rather than text. Also check for Base64URL characters or missing padding. For Hindi text or emoji, check that the ToolsMate Base64 encoder, or any tool you use, works in UTF-8. Otherwise decoded text may come back garbled.

</> 02 ยท UNDERSTAND

How this developer tool works

01

Enter the required information

Use the fields in the tool above and keep units and formats consistent.

02

Run the tool

Review the result shown in the output area.

03

Check the assumptions

Confirm that the result matches your situation before using it for a decision.

</> 03 ยท FORMULA / LOGIC

Which formula or logic is used?

</>UTF-8 text is encoded to Base64.

This describes the core logic used by the tool. Check any assumptions that may affect your result.

โœฆ 04 ยท IMPORTANT

Things to know before using Base64 Encoder / Decoder

01

Use accurate inputs and keep units consistent.

02

Review the assumptions before using the result for a decision.

03

Compare important results with an independent or official source.

? 05 ยท FAQ

Frequently Asked Questions

Is Base64 encoding secure?+

No, Base64 provides no security because anyone can reverse it without a key or password. It is a way of representing data as text. Use encryption such as AES when you need to keep information private.

Why does a Base64 string end with equals signs?+

The equals signs are padding that keep the output length a multiple of four characters. One equals sign means the final group held two bytes. Two equals signs mean it held only one byte.

How much bigger does Base64 make a file?+

Base64 output is roughly 33% larger than the input because every 3 bytes become 4 characters. Line breaks added by some encoders, such as MIME email encoders, increase the size a little more.

What is the difference between Base64 and Base64URL?+

Base64URL replaces the plus sign with a hyphen and the slash with an underscore, and it often drops the padding. These changes make the string safe inside URLs and filenames. JWT tokens use this variant.

Can I decode a JWT token with a Base64 decoder?+

You can read the header and payload by decoding each dot-separated part as Base64URL. Decoding does not verify the signature, though. Never trust the claims in a token until your server has validated it.

Why is my decoded Base64 text showing strange characters?+

The original data was probably binary, such as an image or PDF, which cannot display as readable text. Another cause is a character set mismatch, where UTF-8 text was decoded as Latin-1 or a similar encoding.

Should I use Base64 images in my website CSS?+

Inline Base64 works well for tiny icons under a few kilobytes because it saves an HTTP request. Larger images bloat your CSS, cannot be cached separately, and usually slow page load, so serve those as normal files.

โ—Ž 08 ยท CATEGORY HUBS

Explore TheToolsMate