🔤 Base64 Encode and Decode
By ToolNimba Editorial Team · Updated 2026-06-19
Type some text and press Encode.
This Base64 tool encodes text to Base64 and decodes Base64 back to readable text, both directions in one place. It handles full UTF-8, so accented letters, emoji, and non-Latin scripts survive the round trip without turning into garbage. Switch between Encode and Decode, tick URL-safe output if you need it, and copy the result with one click. Everything runs in your browser, so the text you paste never leaves your device.
What is the Base64 Encode Decode?
Base64 is a way of representing binary data using only 64 printable ASCII characters: the letters A to Z and a to z, the digits 0 to 9, and the two symbols + and /. It exists because many systems were built to carry plain text safely but mangle raw bytes. Encoding data as Base64 lets you push it through email bodies, JSON fields, URLs, and HTML attributes without it getting corrupted. It is an encoding, not encryption: anyone can decode it, so it provides zero secrecy.
The encoding works by reading the input three bytes (24 bits) at a time and splitting those 24 bits into four groups of 6 bits. Each 6-bit group is a number from 0 to 63, which maps to one character in the Base64 alphabet. Three input bytes therefore become four output characters, which is why Base64 output is about 33% larger than the original. When the input length is not a multiple of three, the encoder pads the final group with one or two = characters so the output length stays a multiple of four.
A detail that trips people up is text encoding. Base64 operates on bytes, but text is made of characters, and a single character like é or an emoji can be several bytes in UTF-8. This tool first converts your text to UTF-8 bytes with TextEncoder, then Base64-encodes those bytes, and reverses the process on decode with TextDecoder. That is why it can round-trip "café" or "🚀" correctly, whereas a naive btoa call would throw an error on characters outside the Latin-1 range.
When to use it
- Embedding a small image, font, or icon directly in CSS or HTML as a data URI instead of a separate file request.
- Encoding credentials for an HTTP Basic Authorization header, which expects "user:password" in Base64.
- Inspecting the payload of a JSON Web Token (JWT), whose three sections are Base64URL encoded.
- Safely placing binary or special characters inside a JSON field, an XML document, or a URL query string.
How to use the Base64 Encode Decode
- Choose Encode to turn text into Base64, or Decode to turn Base64 back into text.
- Type or paste your content into the input box. The result updates as you type.
- Optionally tick URL-safe output to swap + and / for - and _ and drop the = padding.
- Press Copy to copy the result, or Swap input and output to feed the result back through.
Formula & method
Worked examples
Encode the word "Man" (3 bytes, a clean block).
- ASCII bytes: M = 77, a = 97, n = 110.
- In bits: 01001101 01100001 01101110.
- Regroup into 6-bit chunks: 010011 010110 000101 101110 = 19, 22, 5, 46.
- Map to alphabet: 19=T, 22=W, 5=F, 46=u.
Result: Man encodes to TWFu
Encode the single letter "M" (1 byte, needs padding).
- ASCII byte: M = 77 = 01001101.
- Only 8 bits, so pad to 12 bits: 010011 010000.
- These map to 19=T and 16=Q, giving TQ.
- One input byte leaves the last block short, so add == padding.
Result: M encodes to TQ==
Round-trip a non-ASCII string, "café".
- UTF-8 bytes: 63 61 66 C3 A9 (é is two bytes, C3 A9).
- Encode those 5 bytes as Base64.
- 5 bytes is one full block (3) plus 2 left over, so the output ends in one = pad.
- Decoding reverses it back to the exact UTF-8 bytes and characters.
Result: café encodes to Y2Fmw6k=
The Base64 alphabet (index to character)
| Index range | Characters |
|---|---|
| 0 to 25 | A B C D E F G H I J K L M N O P Q R S T U V W X Y Z |
| 26 to 51 | a b c d e f g h i j k l m n o p q r s t u v w x y z |
| 52 to 61 | 0 1 2 3 4 5 6 7 8 9 |
| 62 and 63 (standard) | + and / |
| 62 and 63 (URL-safe) | - and _ |
| Padding | = |
Input length, padding, and output length
| Input bytes (mod 3) | Padding added | Output ends with |
|---|---|---|
| 0 (exact multiple of 3) | none | a normal character |
| 1 leftover byte | two = signs | == |
| 2 leftover bytes | one = sign | = |
Common mistakes to avoid
- Treating Base64 as encryption. Base64 hides nothing. Anyone can decode it in seconds, so never use it to "protect" passwords, tokens, or private data. Use real encryption for secrecy.
- Breaking UTF-8 with btoa and atob directly. The raw btoa function throws on characters above code point 255, and atob returns mangled bytes for multibyte text. Always go through UTF-8 bytes first, which this tool does for you.
- Mixing up standard and URL-safe variants. URL-safe Base64 uses - and _ instead of + and / and often drops padding. Decoding a URL-safe string with a strict standard decoder fails. This tool accepts both automatically.
- Forgetting that output grows by about a third. Base64 inflates data by roughly 33% (4 characters per 3 bytes). For large payloads this size bump matters, so do not assume the encoded form is free.
Glossary
- Base64
- An encoding that represents binary data using 64 printable ASCII characters, so it can travel safely through text-only channels.
- Encoding
- A reversible transformation of data into another format. Unlike encryption, it uses no key and provides no secrecy.
- UTF-8
- The dominant character encoding for text. It represents each character as one to four bytes, which Base64 then operates on.
- Padding
- The = characters added to the end of Base64 output so its length is always a multiple of four.
- URL-safe Base64
- A Base64 variant that replaces + and / with - and _ so the result can sit in a URL or filename without escaping.
- Data URI
- A scheme that embeds file contents (often Base64 encoded) directly inside a URL, such as data:image/png;base64,...
Frequently asked questions
What is Base64 encoding?
Base64 encoding represents binary data using 64 printable ASCII characters so it can pass safely through systems that expect text, such as email, JSON, and URLs. It is reversible and provides no encryption or secrecy.
How do I decode a Base64 string?
Paste the Base64 string, select Decode, and the original text appears instantly. This tool handles UTF-8 text and accepts both standard and URL-safe Base64, with or without padding.
Is Base64 encryption or secure?
No. Base64 is an encoding, not encryption. Anyone can decode it without a key, so it offers no security. Never use it to protect passwords or sensitive data. Use proper encryption for that.
Why does Base64 make data bigger?
Base64 turns every 3 bytes of input into 4 output characters, so the encoded result is about 33% larger than the original. The padding = characters add a few more characters at the end.
Does this tool handle emoji and accented characters?
Yes. It converts your text to UTF-8 bytes before encoding and decodes back through UTF-8, so characters like é, ü, Japanese text, and emoji round-trip correctly without corruption.
What is URL-safe Base64?
URL-safe Base64 replaces the + and / characters with - and _ and usually omits the = padding, so the encoded value can appear in a URL or filename without escaping. Tick the URL-safe option to produce it.