Common Base64 Errors and How to Fix Them

Almost every "Base64 decode failed" error falls into one of a small number of categories. Here's how to diagnose and fix each one, and how to check a string before you even try to decode it.

"Invalid character" errors

Standard Base64 only permits A-Z, a-z, 0-9, +, /, and = for padding. This error usually means the string picked up something outside that set along the way — smart quotes or en-dashes introduced by copying from a word processor, stray whitespace pasted in the middle of the string, or a URL-safe string (using -/_) being fed to a decoder that expects the standard alphabet. Check which variant you actually have with the Base64 Validator.

"Invalid padding" / "incorrect padding" errors

Standard Base64's output length must always be a multiple of 4 — the encoder adds one or two trailing = characters to guarantee this. This error means the string you're decoding isn't a multiple of 4 characters, most often because a trailing = was accidentally trimmed (some text editors or "clean up whitespace" tools strip it), or the string was truncated when copied. The fix is usually to re-copy the full string, or, if you know it's URL-safe Base64, re-pad it before decoding standard Base64.

Standard vs. URL-safe mismatches

A string encoded with +// will fail (or silently produce garbage) if decoded as URL-safe, and vice versa. This is especially common with JWTs and tokens, which specifically use URL-safe Base64. If a value came from a URL, cookie, or filename, try the URL-safe tool; if it came from a JSON payload or raw API response, try standard Base64.

Line breaks in the middle of a value

MIME/email Base64 wraps lines at 76 characters (see MIME Base64), which will confuse a decoder expecting a single unbroken line. Strip line breaks before decoding, or use a decoder built to handle wrapped MIME text.

Check before you decode

Rather than guessing from an error message, run the string through the Base64 Validator first — it reports the specific reason a string fails (wrong alphabet, bad padding, wrong length) instead of a generic decode error.

Base64 Encoding Errors — FAQ

"Invalid character" — what does this mean?+

Your string contains a character outside the Base64 alphabet (A-Z, a-z, 0-9, "+", "/", "=" padding) — commonly caused by copy-paste adding smart quotes, or mixing up standard and URL-safe Base64.

"Invalid padding" or "incorrect padding" — what does this mean?+

Standard Base64 output length must always be a multiple of 4, using "=" characters to pad the final group. This error means characters were dropped (often a trailing "=" trimmed by a text editor) or the string was truncated.

Why does my Base64 string work in one language but not another?+

Usually a standard-vs-URL-safe mismatch: one side encoded with "+"/"/" and the other expects "-"/"_" (or vice versa), or one library expects padding and the other omits it.

How can I check if a string is valid before decoding it?+

Use the Base64 Validator tool, which reports the exact reason a string is invalid rather than just failing silently.