SS Toolbox
SS Toolbox
All data is processed locally

Base64 Encoder & Decoder for Text, Images, Data URI and JWT Payloads

Encode UTF-8 text and images to Base64 in your browser, and decode Base64 back to text or preview it as an image. Handles Chinese, emoji and multi-line input, but this is standard Base64 only: URL-safe variants and bare JWT segments need fixing first, and binary data decodes as garbled UTF-8.

Convertion Type
Text
Base64
The Base64 encoding process divides any binary data into groups of 3 bytes (24 bits) and divides these 24 bits into 4 6-bit units. Each 6-bit unit is mapped to an ASCII character, so 3 bytes of binary data are converted to 4 printable characters. The disadvantage is of course that the volume will be 4/3 times the original. This tool uses UTF-8 for character encoding.

What this Base64 tool handles — and what it does not

  1. UTF-8 text in both directions

    Typing text encodes it immediately: TextEncoder converts it to UTF-8 bytes before Base64, so Chinese, Japanese and emoji come out correct instead of throwing the way raw btoa does on non-Latin-1 characters.

  2. Images become Data URIs

    Switch to Image, pick a file, and it is read as data:image/...;base64,... . Paste that Data URI back into the Base64 box to preview it inline; an invalid source shows a fallback message instead of a broken image.

  3. Standard Base64 only, no URL-safe mode

    The - and _ characters are rejected, so JWT payloads and URL-safe tokens must be rewritten to + and / before decoding. Missing = padding is accepted, and spaces, tabs and line breaks are ignored.

  4. Decoding assumes UTF-8

    Base64 of binary data is decoded as UTF-8 text, producing replacement characters instead of an error. Only UTF-8 text round-trips cleanly, so images and other bytes cannot be recovered this way.

  5. Runs locally, but large input can fail

    Nothing is uploaded; text is converted on every keystroke. There is no size guard, and very large text can hit a call-stack error because all bytes are spread into btoa at once.

Base64 encoding and decoding FAQ

Does it support URL-safe Base64 (- and _)?

No. Only the standard + / alphabet works; - or _ throws InvalidCharacterError. Replace - with +, _ with /, then pad the string to a multiple of 4 before pasting it here.

Can I decode a JWT payload here?

Only after conversion. A JWT payload segment is URL-safe Base64 without padding, and this page neither splits a token nor adds missing characters. Paste a rewritten segment; the result is plain text, not parsed JSON.

Can I convert files to Base64 and back?

Only images, and only one direction for files: upload an image to get a Data URI. There is no text-file picker, and decoding never produces a downloadable file — the result is shown as text.

Why does Chinese or emoji work when btoa usually fails?

Because the code converts text to UTF-8 bytes with TextEncoder before calling btoa, then reverses it with TextDecoder. Calling btoa directly on 中文 throws InvalidCharacterError; this page does not.

What happens with binary (non-UTF-8) Base64?

It is decoded as UTF-8, so arbitrary bytes become replacement characters; nothing fails and no error is shown. Use the image preview or a dedicated binary decoder when the bytes must be preserved.

Is there a size limit, and does it upload anything?

Nothing is uploaded and there is no explicit limit; conversion runs synchronously on every keystroke. Large inputs can throw 'Maximum call stack size exceeded', and multi-megabyte text may freeze the tab.

How are padding, whitespace and invalid input treated?

Missing = padding is accepted, and atob ignores spaces, tabs and line breaks. A length of % 4 == 1, or any character outside the alphabet, throws InvalidCharacterError and the UI shows no error message.

Related Tools
SponsorMindElixir