“Invalid Base64” is one of the most frustrating errors in development, because the value usually looks fine. After analysing the kinds of broken values people paste into our decoder, we built a tool that fixes them automatically: the Base64 repair tool.
What breaks Base64?
Base64 is designed to survive text channels, but the channels themselves often transform it:
- Line breaks and spaces inserted by e-mail clients, terminals and editors.
- JSON escaping:
\/instead of/,\nsequences, or\u003dinstead of=. - URL encoding:
%2B,%2F,%3D— and worse,+turned into a space by form decoding. - Base64URL characters (
-,_) where standard Base64 was expected. - Prefixes and wrappers:
data:image/png;base64,, quotes, PEM header lines. - Missing or excess padding after copying part of a value.
How the repair tool works
The tool applies a series of safe transformations in a careful order (for example, it URL-decodes before replacing spaces with +), then validates the result. Every change is listed, so you can see exactly what was wrong with your data — useful for fixing the bug at its source.
The output is canonical standard Base64 that any decoder accepts. If the original was truncated, the missing bytes cannot be recovered, but everything before the cut decodes correctly.
Try it
Paste something like this into the repair tool:
"data:text/plain;base64,SGVsbG8g\nV29ybGQ%3D"
The tool removes the quotes, the data URI prefix, the escaped line break and the percent-encoded padding, and returns SGVsbG8gV29ybGQ= (“Hello World”). Then check the result with the validator. As always, everything runs in your browser.
Comments (0)
Questions, ideas or a bug in “Launched: the Base64 repair tool”? Leave a comment, rate the tool, or reply to others.
No comments yet. Be the first to share your feedback!