Base64 / roundtrip handoff guide
Round-trip Base64 as text or binary without damage
Base64 is not encryption. Decide whether decoded bytes are UTF-8 text or a binary file before restoring them.
Base64 / roundtrip handoff guide
Base64 is not encryption. Decide whether decoded bytes are UTF-8 text or a binary file before restoring them.
Decode as text only after confirming UTF-8. For images, archives, or arbitrary bytes, save binary instead of forcing a display. Do not safely infer MIME or file type from Base64 alone.
UTF-8 text → bytes → decode as UTF-8 text
binary data → bytes → save as binary file
Base64 is encoding, not encryption| Boundary | What to check |
|---|---|
| UTF-8 | Validate the character encoding; do not hide invalid bytes with replacement characters. |
| binary | Keep unreadable bytes binary and confirm the destination format separately. |
| alphabet | Fix standard Base64 +/ versus URL-safe -_. |
| padding | Confirm whether omitted or restored trailing = is allowed. |
Line-wrapped Base64 from a mail or log has whitespace boundaries. Confirm whether it may be normalized; do not mix wrapping with the payload bytes. Choose extension and MIME by contract, not by guessing from the Base64 string.
The existing Base64 tool converts locally. This guide supports the restore decision and never sends input externally.
| case | outcome | check |
|---|---|---|
utf8-text | decode-as-utf8 | Validate UTF-8 before displaying. |
binary-bytes | save-as-binary | Do not coerce arbitrary bytes to text. |
url-safe-alphabet | alphabet-check | Do not confuse -_ with +/. |
missing-padding | padding-check | Confirm whether omitted = is accepted. |
whitespace-wrap | normalize-boundary | Do not mix wrapping whitespace into data. |
unknown-file-format | reject | Do not infer MIME or safety from Base64 alone. |
Do not paste production tokens, signing keys, or personal data into this guide. Use a harmless fixture and a separate secure handoff for sensitive bytes.