You paste a Base64 string into a decoder and instead of text you get an error: invalid character, invalid length, or a flat refusal. The string probably came from a log, a JSON payload, an email or a token, and somewhere between source and clipboard it picked up damage. Base64 errors are rarely mysterious, though. The format uses a small, strict alphabet, so almost every failure is one of a handful of copy accidents, each with a concrete fix. This guide works through them using the free Base64 Text Encoder/Decoder on Ovatly, whose validation errors name the problem instead of guessing.

Contents

  • Quick answer
  • What counts as an invalid character
  • Fix 1: whitespace and line breaks copied in
  • Fix 2: URL-safe characters in a strict decoder
  • Fix 3: missing padding
  • Fix 4: a truncated copy
  • Fix 5: characters from a surrounding JSON string
  • Limitations and honest warnings
  • Common mistakes
  • FAQs
  • Conclusion

Quick answer

When a Base64 string fails to decode, clean it first. Remove spaces and line breaks that crept in during copying, strip surrounding quotes and JSON escape characters, and check the end for missing padding or a cut-off tail. Then paste it into the Base64 Text Encoder/Decoder and press Decode from Base64. This decoder accepts the standard and URL-safe variants, with or without padding, so if a cleaned string still fails here, it is damaged or was never Base64 text at all.

What counts as an invalid character

Base64 represents data with a tight alphabet: the letters A to Z and a to z, the digits 0 to 9, two symbols, and the = padding character. In the standard variant the two symbols are + and /. In the URL-safe variant they are - and _ instead, swapped so the text can sit inside a web address safely.

Anything outside that alphabet does not belong in the string. A space, a line break, a quotation mark, a backslash: none of these are Base64 characters, and a strict decoder stops when it meets one. That strictness is a feature, because silently skipping unknown characters could hand you text that decodes cleanly and is quietly wrong. This tool reports a validation error for input that is not real Base64, and a separate error when the decoded bytes are not valid UTF-8 text.

Fix 1: whitespace and line breaks copied in

Long Base64 values rarely travel in one piece. Email systems wrap lines, terminals break output at the screen edge, and log viewers insert breaks of their own. Copy a wrapped value and you copy the breaks with it, so a string that should read SGVsbG8sIFdvcmxkIQ== arrives as fragments with newlines, and sometimes spaces, between them.

The fix is mechanical: paste the string into a plain text editor, delete every line break and space inside it, and join it into one continuous line before decoding. Work on a copy, not the original log line. If the joined string decodes, the breaks were the whole problem.

Fix 2: URL-safe characters in a strict decoder

A string containing - or _ is usually not corrupted at all. It is the URL-safe variant, common in tokens and links. Strict decoders that only accept the standard alphabet reject those characters as invalid, which makes a healthy string look broken.

Here the fix is to use a decoder that accepts both variants: this one does, so a URL-safe string decodes as pasted. If you ever have to feed a strict decoder instead, the conversion is a plain character swap, - back to + and _ back to /, and nothing else changes. One text shows the difference: "subjects?>" encodes to c3ViamVjdHM/Pg== in standard Base64 and to c3ViamVjdHM_Pg== in the URL-safe variant.

Fix 3: missing padding

Padding is the one or two = signs at the very end of a string, marking how many bytes were in the final partial group, because Base64 works in groups of four characters. Some systems strip padding when storing a value, and some copy operations lose it, leaving a length that is not a multiple of four. Strict decoders refuse that shape outright.

This decoder accepts strings with or without padding, so a missing = will not stop you here. When another tool demands it, restore the padding yourself: add = characters until the length is a multiple of four. A string of length 18, like SGVsbG8sIFdvcmxkIQ, takes two, giving back SGVsbG8sIFdvcmxkIQ==. Padding only ever goes at the end; an = in the middle means something else went wrong upstream.

Fix 4: a truncated copy

The nastiest failure is the one that does not fail. If a copy grabs only part of a string, and the part ends on a group boundary, it decodes without any error into cut-off text. The full encoding of "Hello, World!" is SGVsbG8sIFdvcmxkIQ==. Copy only the first sixteen characters, SGVsbG8sIFdvcmxk, and it decodes happily to "Hello, World", the exclamation mark silently gone.

There is no repair for missing characters, only detection. Compare the decoded text against what you expect: does it end mid-word, does a JSON value lose its closing brace, does a name lose its last letters? Then go back to the source and copy again, selecting the whole value including its padding. If a string ends abruptly without = signs where the data length calls for them, suspect truncation first.

Fix 5: characters from a surrounding JSON string

Base64 values often live inside JSON, and JSON adds its own characters around them. Copy a value carelessly and you take the surrounding double quotes with it, and a quote is not a Base64 character. Worse, JSON writers escape forward slashes as \/. The string for "ÿÿ" is w7/Dvw==, but inside a JSON document it may appear as w7\/Dvw==, and the backslash will stop a decoder cold.

The fix is to copy the value, not its container. Take the text between the quotes only, and if the source is raw JSON, undo its escapes: turn \/ back into /, and watch for \n sequences, a line break written as two characters, which must come out entirely.

Limitations and honest warnings

  • Cleaning cannot invent missing data. Whitespace, quotes and escapes can be removed, and padding restored, but characters lost to truncation are gone. The fix is a fresh copy from the source.
  • A successful decode is not proof the string was healthy. A truncated string can decode into plausible, incomplete text. Sanity-check the output.
  • Not every failure is a character problem. Input that decodes to bytes which are not valid UTF-8 text produces an error here instead of mojibake. That usually means the data was binary, and binary belongs in a file tool.
  • This tool is for text. Images have their own route, the Base64 Image Encoder in the Image Tools category.
  • Decoding proves nothing about trust. Base64 is an encoding, not encryption, and a string that decodes cleanly is still just text anyone could have produced.

Common mistakes

  • Pasting the whole JSON line. Quotes, braces and the key name are not part of the value. Copy only what sits between the quotes.
  • Decoding a wrapped string without joining it. Line breaks from an email or terminal are copy artefacts.
  • Converting URL-safe strings by hand when the decoder already accepts them. This tool takes both variants as they are; manual swaps are one more chance for a typo.
  • Adding padding in the middle, or guessing at it. Padding belongs only at the end, and only enough to make the length a multiple of four.
  • Assuming an error means the data is gone. Most invalid character errors are clipboard damage, fixed in a minute.
  • Trusting a clean decode of a suspiciously short string. Compare the output with what the value should contain.

FAQs

Why does my Base64 string have an invalid character? Because something outside the Base64 alphabet got into it: usually a space, a line break, a surrounding quote or a JSON escape backslash picked up during copying. Clean those out and decode again.

Do I need to convert a URL-safe string before decoding it here? No. This decoder accepts standard Base64 and the URL-safe variant (with - and _), with or without padding, so both forms decode as pasted.

My string is missing its = padding. Is it broken? Not necessarily. Some systems strip padding, and this decoder accepts strings without it. If another tool insists, add = characters at the end until the length is a multiple of four.

The string decoded but the text looks cut off. What happened? Probably a truncated copy. A partial string that ends on a group boundary decodes without error into incomplete text. Go back to the source and copy the whole value, padding included.

What if the tool says the decoded bytes are not valid UTF-8 text? Then the data behind the string was probably binary rather than text. This tool reports that instead of printing mojibake, and binary data belongs in a file tool.

Conclusion

Almost every invalid character error is a copying accident with a five minute fix: join the wrapped lines, drop the quotes and escapes, check the padding, and copy again when the tail looks short. Paste the cleaned string into the Base64 Text Encoder/Decoder and it will either decode or tell you plainly that what you have is not Base64 text. To see the format doing a real job, How to Encode Basic Auth Credentials with Base64 builds a working login header with it. For more tools like these, see the Developer Tools guide archive.