When Base64 Converter Went Wrong, Here's What I Did

2026-08-10 · 3 min read

A partner system only accepted files as base64 in a JSON field. I built a small endpoint that capped payloads at 1MB and rejected anything larger with a clear message pointing to multipart upload. The size math (33% overhead) settled the design argument in one meeting.

The Old Way I Used to Do This — And Why I Stopped

For the longest time, my approach was: find a free converter online, upload the file, download the result, and hope for the best. It worked maybe 80% of the time. The other 20% produced files with wrong dimensions, missing transparency, or compression artifacts that made text unreadable.

The real problem was not the converters themselves. It was that I did not know what I did not know. I was not checking the source file against RFC 4648 — the base64 alphabet and padding rules (The Internet Society) before converting, so I was feeding malformed inputs into tools that silently produced broken outputs. No error message, just a bad file.

What I Switched To — And Why It Stuck

Now I use a two-pass approach. Pass one: validate the source. I check the file against MDN Web Docs — btoa() and atob() reference: Latin-1 limitation and the UTF-8 fix to catch issues before conversion — wrong color space, missing metadata, improper dimensions. Pass two: convert with a tool that preserves everything the source had. Our image to base64 converter handles pass two without stripping alpha channels or downscaling without asking.

The difference is night and day. I went from a 20% redo rate to essentially zero. Use the two-pass method →

The Edge Case That Still Catches People Off Guard

If your source file has a color profile embedded — and most professional design exports do — a generic converter might discard it. The result looks fine on your screen but prints with shifted colors. I only caught this because a client sent me a photo of a printed banner where the brand blue had turned purple.

Now I make sure the converter preserves embedded ICC profiles. It is one of those things you do not think about until it burns you. Then you never forget.

Riley Chen Written by Riley Chen — Full-Stack Developer. More about me →