Base64 encoder / decoder

Load sample Encode is Hello World! → SGVsbG8gV29ybGQh. RFC 4648, not base64url.

Docify's Base64 tool encodes UTF-8 text with btoa(unescape(encodeURIComponent())) and decodes with decodeURIComponent(escape(atob())) (RFC 4648 alphabet, not base64url). Load sample Encode writes SGVsbG8gV29ybGQh for ASCII Hello World!. Decode of that same string writes Hello World!. File encode uses FileReader.readAsDataURL and the payload after the comma. Download is a text/plain dump, not a binary file restore. Nothing is uploaded.

Plain text
Base64 output

How it works

  1. Encode and Decode are buttons, not as-you-type. Load sample fills ASCII Hello World! (Encode mode) and does not run Encode. Encode of that sample writes SGVsbG8gV29ybGQh. Encode stays disabled while the box is empty.
  2. Text encode runs btoa(unescape(encodeURIComponent(input))) so the UTF-8 bytes become RFC 4648 Base64. Text decode is decodeURIComponent(escape(atob(input))). Decode of SGVsbG8gV29ybGQh writes Hello World!. The alphabet uses +, /, and = padding, not base64url.
  3. Upload file reads the file with FileReader.readAsDataURL, then takes the payload after the comma. Encode mode writes that string to the output. Decode mode writes it to the input so you can click Decode. Load sample is the text path, not this FileReader path.
  4. Download saves the output as a text/plain blob (encoded.txt or decoded.txt). It does not restore an image or PDF as a typed binary file. A malformed alphabet shows Failed to decode: Invalid Base64 string.

FAQ

Does this tool upload my text or files?
No. Encode, decode, file read, copy, and download run in your browser. The page does not send the text or file to a server.
How is text encoded and decoded?
Encode runs btoa(unescape(encodeURIComponent(input))) so UTF-8 text becomes standard Base64. Decode is the reverse: decodeURIComponent(escape(atob(input))). The alphabet is RFC 4648 Base64 (+, /, = padding), not base64url. Load sample is ASCII Hello World!. Encode writes SGVsbG8gV29ybGQh. Decode of that same string writes Hello World!.
How are files encoded?
Upload file uses FileReader.readAsDataURL, then takes the payload after the comma. That string is the file bytes as standard Base64. In decode mode, upload puts that payload into the input box so you can click Decode. Load sample is a text path: it fills Hello World! and does not run Encode. File encode is a separate FileReader path.
Does decode restore an image or PDF as a binary file?
No. Download always writes the output string as text/plain (encoded.txt or decoded.txt). Text decode treats the bytes as UTF-8 via decodeURIComponent. There is no file-type-aware binary restore. Load sample fills Hello World! and does not run Encode. Encode writes SGVsbG8gV29ybGQh. Encode stays disabled while the box is empty. A malformed alphabet shows “Failed to decode: Invalid Base64 string”.

Related