Decodex

DECODEX · BASE64

How to fix Base64 decoding errors

Diagnose which layer failed: Base64 syntax, text interpretation, or file restoration. This page is the diagnostic starting point; the other guides explain each layer in depth.

Start with a known-good value

Paste SGVsbG8= into the text decoder. If Hello appears, the basic conversion works. Test the failing value separately. A rejected Zg= is a syntax error; /w== has valid Base64 syntax but its restored FF byte is not valid UTF-8. These failures need different fixes.

Choose text decoding or file decoding

For text, select the original character encoding. For an image, PDF or other binary file, save the Base64 value in a text file and use File decoding. The text output is not a file preview. Our synthetic fixture below deliberately includes 00 and FF to detect accidental text conversions that would damage binary data.

Check what happened before the decoder

Copy only the value from JSON, without quotes. The text decoder needs the portion after the comma in a data URL; File decoding also accepts a complete Base64 data URL. Percent escapes belong to URL decoding. A truncated payload cannot be recovered merely by adding padding. Follow the URL transport guide when a value works locally but fails after transmission.

Verified experiments

Input / operationExpected resultBrowser result
SGVsbG8=HelloNot run
Zg=
Base64 → UTF-8
Error (expected rejection)Not run
A
Base64 → UTF-8
Error (expected rejection)Not run
/w==
Base64 → UTF-8
Error (expected rejection)Not run
00 ff 01 80
Base64 → bytes
AP8BgA== → 00 ff 01 80Not run
00 ff 01 80
SHA-256
edc81f7e4ee358fb91e94bd9bd74079c3dcba36f40f2c8a36e7ae0567afecc8fNot run

What the results mean

The FF byte is valid binary data but invalid UTF-8. A text conversion error does not mean the file is corrupt. The four-byte fixture restores exactly and has the same SHA-256 before and after conversion.

How to reproduce

Run the table, then decode SGVsbG8= in the text tool as a control. Save AP8BgA== as a .txt file and use File decoding to restore four bytes. Compare bytes or SHA-256 instead of renaming a file and assuming success.

Base64 →

Verification method

These fixed, public fixtures run against the same file codec and character codecs used by the converter. The JavaScript cases additionally check browser-native btoa, TextEncoder, URLSearchParams and SHA-256. Expected outputs are published before any script runs; the button shows actual results in your browser. No input is uploaded.

JavaScript · guide-cases.js · JavaScript · file-codec.js

Scope and limitations

Checked on 2026-10-21. This is a correctness check with small fixtures and one 100,000-character case, not a speed benchmark or a guarantee for every file. The four-byte file is synthetic binary data, not a PNG or PDF. SHA-256 equality checks byte preservation; it does not establish that a file is safe to open. Results can depend on browser support.

References

Choose a guide for your problem