Base64 Encode / Decode
Understand Base64 Encode / Decode
Base64 rewrites arbitrary bytes as 64 ordinary text characters so binary data can travel through systems that only carry text.
How it works
Base64 reads the input three bytes (24 bits) at a time and emits four characters drawn from a fixed alphabet: A–Z, a–z, 0–9, plus + and /. Four characters carrying three bytes is exactly where the roughly 33% size increase comes from, and = padding fills the last group when the input length is not a multiple of three. Text is encoded as UTF-8 first, so é becomes the two bytes C3 A9 before any Base64 happens.
When to use it
- Embedding a small image, icon, or font directly in CSS or HTML as a data URI.
- Carrying binary attachments through email (MIME) or inside a JSON payload, neither of which can hold raw bytes.
- Reading the payload of a JWT or an HTTP Basic Authorization header while debugging a request.
- Storing a certificate or private key in a text config file — PEM is Base64 with header lines around it.
Watch out for
- Base64 is encoding, not encryption. Anyone can decode it in a second, so it hides nothing: never use it for a password, an API key, or personal data.
- This tool uses the standard alphabet with + and /. JWTs, URLs, and filenames use Base64URL, which substitutes - and _ and often drops padding — a raw JWT segment fails here until you swap those characters back and pad the length to a multiple of four.
- Decoding renders the result as UTF-8 text, so the Base64 of a PNG or a ZIP comes back as unreadable characters. That is the correct answer: the payload is binary, not text.
- The ~33% growth is charged on every page load when the payload is inlined, because an inlined asset cannot be cached separately from the document that contains it.
Not the right tool for: Protecting a secret. Use AES encryption if you need the value back, or a hash if you never do.
Frequently Asked Questions
What is Base64 used for?
Base64 is commonly used to encode binary data (images, files) so it can be safely transmitted over text-based protocols like HTTP or email.
Does Base64 have padding?
Yes, standard Base64 uses "=" padding characters to make the output length a multiple of 4. Some implementations omit padding (e.g., JWT uses Base64URL without padding).
What is the URL-safe Base64 variant?
URL-safe Base64 replaces "+" with "-" and "/" with "_" to avoid conflicts with URL-reserved characters. JWT tokens use this variant.
How to Use Base64 Encode / Decode
- Paste or type your input in the input area above.
- The tool processes your input automatically or click Run.
- Copy or download the result using the action buttons.
- Use Ctrl+Enter to run quickly from the keyboard.