Base64 Encoder / Decoder
Encode and decode Base64 instantly — text or images. Full UTF-8 support (Korean, emoji, CJK), a URL-safe option, and everything stays in your browser.
Type in either box — the other updates instantly, and encoding is UTF-8 safe.
Image → Base64
Base64 → Image
Everything runs locally with FileReader — your image is never uploaded.
What Base64 actually encodes, and why it exists
Computers store everything as raw bytes, but many of the pipes data travels through — email bodies, JSON fields, URL query strings, HTML attributes — were built to carry printable text, not arbitrary binary, and can strip high-bit bytes or choke on reserved symbols. Base64 makes that irrelevant: it repackages any bytes into a string built only from 64 safe characters (A–Z, a–z, 0–9, +, /), so the result can sit inside a JSON string, a JWT, an <img> src="data:..." attribute, or an email attachment without anything downstream misreading it.
It's a transport encoding, not compression and not encryption — the output is always larger than the input, and anyone can decode it back with no key. Its only job is making binary data survive text-only channels intact.
Using this encoder / decoder
- Text tab: choose Encode or Decode, then type or paste into either the Text box or the Base64 box — the other box fills in live. Encoding reads your input as UTF-8 bytes first, so Korean, Japanese, Chinese and emoji encode and decode losslessly, not just plain ASCII.
- URL-safe checkbox: tick it before encoding for a URL, filename, or JWT segment. Decoding accepts either alphabet automatically, so you never need to untick it just to paste something in.
- Image tab: drop or choose a file for a ready-to-use
data:URI plus the raw Base64 payload. To reverse it, paste a Base64 string or data URI into the decode box, preview, then download the reconstructed file.
The mechanics: 6-bit groups and padding
Base64 works by regrouping bits, not bytes. Input bytes are 8 bits each, but the 64-symbol alphabet only needs 6 bits per character (2⁶ = 64). The encoder takes 3 input bytes (24 bits) at a time and re-slices those 24 bits into four 6-bit chunks, each mapped to one output character — a 3-bytes-in → 4-characters-out ratio, which is exactly why output is always about 33% larger than the source.
When the input length isn't a multiple of 3, the last group is short. The encoder pads the missing bits with zeros and appends = characters so the decoder knows how many trailing bits were real data. One leftover byte yields ==; two leftover bytes yield a single =; a clean multiple of 3 needs no padding.
Worked examples
Hi! is 3 bytes: H=72, i=105, !=33, i.e. 01001000 01101001 00100001. Re-sliced into four 6-bit groups — 010010 000110 100100 100001 — that's decimal 18, 6, 36, 33, which map to S, G, k, h. Result: SGkh. Because 3 bytes is a full group, there's no padding.
Hi is only 2 bytes (16 bits). That's not a clean 3-byte group, so the encoder pads it out and produces 3 real characters plus one filler: SGk=. The lone = tells the decoder that the last character only carried 4 real data bits, not 6.
안녕 looks like 2 characters, but each Korean syllable is 3 bytes in UTF-8, so the real input is 6 bytes — a clean multiple of 3. Encoding those 6 bytes gives 7JWI64WV, no padding at all. This tool converts text to UTF-8 bytes before encoding, so Korean, CJK and emoji round-trip exactly.
How much bigger does Base64 make things?
Every 3 input bytes become 4 output characters, so output size is predictable — useful when deciding whether to embed an image as a data URI instead of linking to it as a file.
| Input size | Base64 output size | Overhead |
|---|---|---|
| 2 bytes | 4 characters | padded to a full group |
| 100 bytes | 136 characters | +36% |
| 1 KB (1,024 B) | ~1,368 characters | +33.6% |
| 100 KB image | ~133 KB of text | +33.3% |
| 1 MB file | ~1.33 MB of text | +33.3% |
The overhead converges to exactly 4/3 (≈33.3%) for larger inputs; small inputs look worse only because of the fixed padding on the last group.
Standard vs. URL-safe Base64
Two of the 64 alphabet characters — + and / — are meaningful symbols inside URLs and file paths, and = padding is reserved in query strings. RFC 4648 §5 defines a URL-safe variant that swaps those two characters and drops the padding, so the string needs no escaping inside a URL, filename, or JWT segment:
| Position | Standard Base64 | URL-safe Base64 |
|---|---|---|
| 62nd symbol | + | - |
| 63rd symbol | / | _ |
| Padding | = / == | omitted |
For example, the 3 bytes 0x01 0x0f 0xfe encode to AQ/+ in standard Base64 but AQ_- in URL-safe form — same data, characters swapped, padding dropped. Tick the URL-safe box before encoding if the output is headed into a URL, a filename, or a JWT; leave it off for JSON payloads or anything else that doesn't care about those symbols.
Common mistakes
- Assuming Base64 is encryption. It has no key or secret — anyone can decode it instantly. Never use it to "hide" passwords or personal data; it only changes the character set, not the confidentiality.
- Encoding non-Latin1 text with a naive
btoa()call. Plainbtoa()only understands code points 0–255, so Korean, emoji, or most CJK text throws or corrupts. Convert to UTF-8 bytes first, which this tool does automatically. - Mixing the two alphabets by hand. Swapping
+//for-/_without also handling the padding causes silent decode failures in stricter parsers. - Forgetting the data URI prefix matters. An
<img>tag or CSSbackground-imageneeds the fulldata:image/png;base64,...string, not just the raw payload — this tool gives you both, separately. - Base64-encoding large files "to save space." It does the opposite, inflating size by roughly a third — use it for portability, not storage efficiency.
What this tool doesn't do
This is encoding, not compression or encryption, and it doesn't validate that decoded image bytes form a well-formed file — if you paste corrupted or truncated Base64, the browser's image preview may simply fail to render. For genuinely sensitive data, encrypt first and Base64-encode the ciphertext only if you need it in a text-safe channel.
Sources & further reading
- RFC 4648 (IETF) — the Base64, Base64url and Base32 encoding standard, including padding rules
- MDN Web Docs — how Base64 works in browsers, btoa/atob and Unicode pitfalls
- RFC 2397 (IETF) — the data: URL scheme used for inline Base64 images
- The Unicode Consortium — UTF-8 byte encoding that text must pass through before Base64
Frequently asked questions
What is Base64 and when do I use it?
Base64 turns any binary data into plain ASCII text so it can travel safely through channels built for text — data URIs that embed images in HTML or CSS, JSON and JWT tokens, and email attachments. Use base64 encode to pack data into a string, and base64 decode to get the original bytes back.
Why does Korean, emoji and CJK text encode correctly here?
Many quick scripts call btoa() directly, which only handles Latin-1 and mangles anything else. This base64 encoder decoder first converts your text to UTF-8 bytes with TextEncoder, so Korean, Japanese, Chinese and emoji round-trip perfectly, and decoding uses TextDecoder to rebuild the exact original text.
What is URL-safe Base64 (Base64URL) and when do I need it?
Standard Base64 uses + and / plus = padding, which get escaped inside URLs, query strings and JWTs. URL-safe Base64 (RFC 4648 §5) replaces + with -, / with _, and drops the padding. Tick the URL-safe option to produce it; decoding accepts both variants automatically.
How do I convert an image to a Base64 data URI and back?
On the Image tab, drop or choose a file to get its full data URI plus the raw Base64 — ready to paste into an <img>, a CSS background or JSON. To go the other way, paste a Base64 string or data URI to preview the picture, then download it. It works as an image to base64 data uri converter both ways.
Is my text or image uploaded to a server?
No. Everything runs 100% in your browser — text uses btoa/atob with TextEncoder, and images are read locally with FileReader, so nothing is uploaded. Only your last text and the URL-safe option are saved to this browser's local storage for convenience; image data is never stored.