Quick answer
Valid Base64 uses only A–Z, a–z, 0–9, +, / and optional padding with =.
Base64 Invalid Input
Valid Base64 uses only A–Z, a–z, 0–9, +, / and optional padding with =. Invalid characters, wrong length, or bad padding cause decode errors.
Common causes
- Characters outside Base64 alphabet (e.g. spaces, newlines, or special chars in the middle).
- Wrong padding: length not multiple of 4 or incorrect = placement.
- URL-safe Base64 (e.g. - and _) passed to strict decoder without mapping.
How to fix
- Use only A–Z, a–z, 0–9, +, / and = for padding. Strip spaces/newlines before decode.
- Ensure length is multiple of 4; add = padding if needed (e.g. one or two = at end).
- For URL-safe Base64, replace - with + and _ with / before decoding.
- Use the Base64 Encoder/Decoder to validate and decode.
Examples
Bad
SGVsbG8gV29ybGQ=
Good
SGVsbG8gV29ybGQ=
FAQ
- What is valid Base64?
- Only A–Z, a–z, 0–9, +, / and = for padding. No spaces or other characters in the encoded string.
- Why does decode fail with 'invalid character'?
- The string contains a character not in the Base64 alphabet. Remove or replace it (e.g. strip whitespace).
Fix it now
Try in validator (prefill this example)