Skip to content
uencoder
TASK

Fix common Base64 decoding errors

Why a Base64 string fails to decode — missing padding, URL-safe alphabets, stray whitespace — and the exact steps to repair each case.

  1. 1

    Base64 encodes every 3 bytes into 4 characters, so a valid string's length (ignoring whitespace) is always a multiple of 4. When a decoder reports INVALID_BASE64, one of three causes is almost always responsible.

  2. 2
    Base64 Decoder →

    Paste the failing string and try decoding with the standard alphabet first. The error message distinguishes invalid characters from invalid length.

  3. 3

    Cause 1 — missing padding: if the length is 2 or 3 modulo 4, append '=' characters until the length is a multiple of 4. Cause 2 — URL-safe alphabet: tokens and URL parameters use '-' and '_' instead of '+' and '/'; swap them before decoding. Cause 3 — stray whitespace or line breaks: strip spaces and newlines that MIME transport may have inserted.

  4. 4
    Base64 Encoder →

    Round-trip check: encode a known plaintext and compare the output with your broken string character by character to spot an alphabet or padding difference.

Frequently asked questions

Why do some Base64 strings end with '='?
Padding. When the input is not a multiple of 3 bytes, one or two '=' characters are appended so the output length is a multiple of 4. Padding can sometimes be inferred, but strict decoders require it.
Is Base64 encryption?
No. Base64 is a reversible encoding with no secret. It is used to transport binary data through text-only channels, never to protect it.

Workflows that solve this

Convert Ascii85 to Base64
Decode Ascii85 and re-encode as Base64 for wider compatibility.
PIPELINE
Convert Base2048 to Base64
Decode Base2048 (emoji) and re-encode as Base64 for standard transport.
PIPELINE
Convert Base32 to Base64
Decode a Base32-encoded string into raw bytes and re-encode as Base64 for more compact representation.
PIPELINE
Convert Base58 to Base64
Decode Base58 and re-encode as Base64 for standard compatibility.
PIPELINE
Base64 encode then decode round-trip
Encode text to Base64 and decode it back to verify the round-trip preserves the original data.
PIPELINE
Convert Base64 to Base85
Decode Base64 and re-encode as Base85 for compact representation.
PIPELINE
Convert Base64 to Hex
Decode a Base64 string into raw bytes and re-encode it as hexadecimal for inspection or interop.
PIPELINE
Blowfish Encrypt then Base64
Blowfish encrypt then Base64-encode for text-safe transport.
PIPELINE
Decode a Basic Auth credential pair
Decode the Base64 portion of an HTTP Basic Authorization header into username:password.
PIPELINE
DES Encrypt then Base64
DES encrypt then Base64-encode for legacy compatibility.
PIPELINE
Encode a JSON payload for URL transport
Prepare a JSON document for a URL parameter: pretty-print, Base64-encode, then percent-encode — the exact inverse of the nested-parameter decode chain.
PIPELINE
AES encrypt then Base64 encode
Encrypt plaintext with AES and encode the ciphertext as Base64 for text-safe transport.
PIPELINE
Hash content and encode as Base64
Compute a hash of the input and encode the hash digest as Base64 for compact transport.
PIPELINE
Convert Hex to Base64
Decode a hexadecimal string into raw bytes and re-encode it as Base64 for compact transport.
PIPELINE
HMAC Sign then Base64 Encode
Generate HMAC signature then Base64-encode for API auth headers.
PIPELINE
Morse Encode and Base64 Transport
Encode text as Morse code then Base64-encode for digital transport.
PIPELINE
Decode and format a JWT payload
Parse a JWT token, extract its payload, and format the JSON for inspection.
PIPELINE
RC4 Encrypt then Base64
RC4 encrypt then Base64-encode for transport.
PIPELINE
RIPEMD-160 Hash then Base64
Compute RIPEMD-160 hash then Base64-encode for transport.
PIPELINE
Shuffle Text and Base64 Encode
Shuffle text characters then Base64-encode the result.
PIPELINE
Unicode Escape and Base64 Encode
Unicode-escape text then Base64-encode for ASCII-safe transport.
PIPELINE
URL Encode then Base64 Double Encode
URL-encode then Base64-encode for double encoding in API payloads.
PIPELINE
Decode nested URL parameter (Base64 JSON)
Unwrap a URL parameter that carries URL-encoded Base64 JSON into readable, formatted JSON.
PIPELINE
UUencode then Base64
UUencode text then Base64-encode the result for double encoding.
PIPELINE
Generate UUID and Base64 Encode
Generate a UUID then Base64-encode it for compact storage.
PIPELINE

Learn more

Want to understand why?

Related tools