What is Base64?
Base64 is an encoding scheme that maps arbitrary binary bytes to a 64-character ASCII alphabet (A-Z, a-z, 0-9, +, /, plus = for padding). It exists because many transport channels, email headers, URLs, JSON strings, XML attributes, were designed for printable text and choke on raw bytes like 0x00 or 0xFF. Base64 is the universal "wrap any bytes in a safe string" envelope.
Base64 is encoding, not encryption. Anyone holding the string can decode it back to the original bytes without a key. Use it to transport data, never to hide it.
The output is always about 33 % larger than the input (3 input bytes → 4 output chars). That overhead is the cost of restricting yourself to a printable alphabet.
How to use this tool
The toolbar has three modes, pick the one that matches what you're doing:
- Encode, type or paste plain text, get standard Base64 back. UTF-8 input works (emoji, accented characters, Asian scripts).
- Decode, paste a Base64 string, get the original text back. The decoder strips whitespace and accepts both standard and URL-safe variants automatically.
- URL-safe, same as Encode but produces URL-safe Base64:
+becomes-,/becomes_, padding=is dropped.
Hit Sample to load a known-good string for the active mode, then hit ↕ Swap to flip input and output (handy when you want to round-trip-verify a value). Output updates on every keystroke after a short debounce.
Standard vs URL-safe Base64
Standard Base64 (RFC 4648 §4) uses + and / in its alphabet, which collide with reserved characters in URLs and filenames. URL-safe Base64 (RFC 4648 §5) substitutes - for + and _ for /, then drops the trailing = padding because URLs hate it too.
You'll see URL-safe Base64 in:
- JWTs, header, payload, and signature segments are all URL-safe Base64
- OAuth 2.0 PKCE, the
code_challengeis a URL-safe Base64 SHA-256 of the verifier - Web Push, VAPID keys and endpoint payloads
data:URLs with binary content embedded in HTML/CSS
Standard Base64 is what you get from btoa() in JavaScript, base64 on the command line, and most language standard libraries by default.
UTF-8 and the `btoa` gotcha
JavaScript's built-in btoa() only accepts strings where every character has a code point ≤ 255. Pass it "héllo" and it throws InvalidCharacterError. The fix is to encode the string to UTF-8 bytes first, then Base64 those bytes, which is exactly what this tool does internally. Your input is treated as UTF-8 throughout, so emoji, RTL scripts, and CJK characters round-trip cleanly.
If you're decoding a string produced by a non-UTF-8 system (some legacy Windows-1252 emails), the bytes will decode but the resulting characters may be mojibake. That's a charset problem, not a Base64 problem.
Common gotchas
- Whitespace inside the string, newlines and spaces are not part of the alphabet but are commonly inserted for line-wrapping (PEM keys, MIME bodies). The decoder strips them before decoding. Most tools should.
- Missing or wrong padding, standard Base64 pads to a multiple of 4 with
=. If you decodeSGVsbG8(no padding) some libraries reject it. The decoder here re-adds padding when missing. - Mixing standard and URL-safe in one string, the decoder handles either, but if a string contains both
+and-something has gone wrong upstream. - It's not a checksum, Base64-encoding a value doesn't detect corruption. Pair it with a hash if integrity matters.
- Don't Base64 large files in the browser tab, for files over a few megabytes, use a streaming command-line tool. This page lives in your tab's memory.
Privacy
Encoding and decoding both run entirely in your browser using the native btoa / atob and TextEncoder / TextDecoder APIs. Nothing is uploaded to any server. Recent inputs are saved only to your browser's local storage and can be cleared from the "Recent" card.