What Is Base64 and What Is It For?
Base64 is a way to represent any binary data — text, images, ZIPs, anything — using only 64 safe printable characters: A–Z, a–z, 0–9, +, and /, with = for padding. It exists because many channels were built for text only: email (MIME), JSON, XML, HTTP headers, and URLs all choke on raw bytes. Base64 wraps binary in a text-safe envelope so it can ride through those systems untouched.
The trade-off is size: every 3 bytes become 4 characters, so Base64 data is about 33% larger than the original. That is the rent you pay for text-safety — worth it for an auth header, wasteful for a 4 MB hero image.
How Base64 Encoding Actually Works
The algorithm is satisfyingly mechanical: take the input in groups of 3 bytes (24 bits), split those into four 6-bit chunks, and map each 6-bit value (0–63) to one character of the alphabet. “Man” becomes TWFu: M=77, a=97, n=110 → binary 01001101 01100001 01101110 → 010011 010110 000101 101110 → T, W, F, u. When the input is not a multiple of 3, the last group gets zero-padded and one or two = characters pad the output to a multiple of 4 — which is why valid Base64 always has a length divisible by 4 (ignoring whitespace), a fact this tool checks for you on decode.
UTF-8: Why Emoji and CJK Break Naive Encoders
The classic bug: btoa("héllo") throws, and btoa("😀") produces garbage. JavaScript strings are UTF-16; btoa expects one byte per character. Naive fixes like btoa(unescape(encodeURIComponent(text))) work until they silently mangle multi-byte characters. This tool does it properly: TextEncoder converts your string to UTF-8 bytes first, then encodes those bytes, and decoding reverses through TextDecoder. Emoji, accented characters, Chinese, Japanese, Arabic — all round-trip exactly, which you can verify by decoding your own output.
Standard vs URL-Safe Base64
Standard Base64 uses + and /, both of which have special meanings in URLs and filenames. The URL-safe variant (RFC 4648 §5) swaps them for - and _ — that is what JWTs, URL parameters, and many APIs emit. This tool implements the standard alphabet and tells you clearly when it sees URL-safe input instead of failing mysteriously. Converting is trivial: replace - with + and _ with / (and re-pad with =) before pasting.
Encoding Files and Detecting the Original Format
Switch to file mode and any file becomes a Base64 string — the same encoding a JSON API would carry. Going the other way, the decoder sniffs the recovered bytes: magic numbers identify JPEG (FF D8 FF), PNG (89 50 4E 47), PDF (%PDF), ZIP/Office (PK), MP4, MP3, WebP, WOFF2 fonts, and 20+ more formats, while text-shaped data is checked for UTF-8 validity. You get a labeled result and a one-click download with the correct extension — no rename-the-.bin dance.
Base64 Is Encoding, Not Encryption
Worth engraving somewhere: Base64 provides zero secrecy. It is a reversible alphabet mapping that anyone can undo in milliseconds — “encrypted” passwords in a config file are not encrypted at all. Use Base64 to transport data safely through text-only channels, and use real cryptography (AES, proper key derivation, or your platform’s secret manager) to protect it. If you can read a credential after running it through this tool, so can anyone who has the file.
Common Base64 Errors and How to Fix Them
- “Length is not a multiple of 4” — padding characters were lost, usually by a URL parser or spreadsheet. Re-add
=until the length divides by 4. - “Characters outside the standard alphabet” — you pasted URL-safe Base64 (
-/_) or adata:URI prefix. Strip thedata:image/png;base64,prefix and convert the alphabet as described above. - Gibberish after decoding text — the bytes were never UTF-8 (a binary file, or a different encoding like Windows-1252). The tool detects this and offers a binary download instead of pretending it is text.
- Newlines in the input — email/MIME Base64 wraps at 76 characters. This tool strips whitespace automatically, so wrapped input decodes fine.
Step-by-Step: Using the Base64 Encoder/Decoder
- Pick the direction. Encode (text or file → Base64) or Decode (Base64 → text or file), and toggle file mode if you are working with a file rather than typed text.
- Paste or drop your input. Encoding is live as you type (80 ms debounce); files are read entirely in your browser.
- Read the result. Text output appears directly; binary output is labeled with its detected format and size.
- Copy or download. Copy for API payloads and headers; download to recover the original file from a Base64 blob.
- Round-trip check. Encode a string, decode it back, confirm the match — the fastest way to trust an unfamiliar pipeline.
Ready to Encode or Decode?
You know how the 6-bit mapping works, why UTF-8 handling decides whether emoji survive, how to spot URL-safe variants, and what the tool does with binary payloads. Scroll back up, paste your input, and convert it in a keystroke — entirely in your browser, nothing uploaded.
