Base64 Encoder / Decoder
Encode text to Base64 or decode Base64 back to text. URL-safe mode supported.
- Free · no sign-up
- Instant results
- Privacy-friendly
Other Developer Tools
What Base64 is for
Base64 rewrites arbitrary binary data using only 64 printable characters, so it can travel through channels that were designed for text. That is the whole purpose: email bodies, JSON string values, HTML data URIs, HTTP headers, and certificate files are all text-only, and raw bytes passing through them get mangled.
Encoding takes three bytes at a time and expresses them as four characters, which is why Base64 output is always about 33% larger than the input. That overhead is the price of safe transport, and it is worth remembering before you inline a large image as a data URI.
Standard versus URL-safe
The standard alphabet ends with + and / and pads the output with = so its length is always a multiple of four. That is fine inside a JSON value or an email, and a problem in a URL: + means a space in a query string, / is a path separator, and = separates a parameter from its value. Put standard Base64 in a URL without escaping it and it will be corrupted on arrival.
URL-safe mode fixes this by substituting - for + and _ for /, then dropping the = padding entirely. This is the variant defined in RFC 4648 section 5 and it is what JSON Web Tokens, OAuth parameters, and most modern APIs use. If a value you are decoding contains - or _ but no + or /, it is almost certainly URL-safe. Pick the matching mode and it will decode cleanly.
Base64 is not encryption
This is the single most consequential misunderstanding about Base64, and it causes real security incidents. Encoding is fully reversible by anyone, with no key and no secret — the button on this page does exactly that. A Base64 string looks scrambled to a human, which is precisely why it gets misused as if it were protection.
A password, API key, or access token stored as Base64 is stored in plaintext with extra steps. Anything genuinely confidential needs real cryptography: a password hash such as bcrypt or Argon2 for credentials you verify, and authenticated encryption for data you need to read back. HTTP Basic authentication is a good illustration — it Base64-encodes your username and password purely for transport, which is why it is only ever acceptable over HTTPS.
When decoding fails
Two causes account for nearly every failure. The first is a mismatched alphabet — feeding URL-safe input to a standard decoder, or the reverse. The second is truncation: Base64 length must be a multiple of four once padding is accounted for, so a string copied out of a wrapped terminal or a line-broken email often loses characters. Copying the value directly from its source rather than from a rendered view usually fixes it.
It is also worth knowing that decoding produces bytes, not necessarily readable text. If the original data was an image or a compressed archive, the decoded output will look like noise in a text box — that is correct behaviour, not an error.