# Base64 decode and encode

Decode or encode Base64 in your browser. The direction is detected from what you paste. URL-safe Base64, MIME line breaks and data URLs work; decoded images show a preview and download. Nothing is uploaded.

Page: https://toolkitnow.org/tools/base64/

Paste Base64 to decode it, or type text to encode it. The direction follows what you paste; the gray text is an example.

## Good to know

### Which way

Base64 that decodes to readable text, or to an image, PDF or ZIP, is decoded. Anything else is encoded, including short words made of Base64 letters, such as `test` or `file`. If the guess is wrong, use Decode instead or Encode instead.

### URL-safe

Base64url (RFC 4648, section 5) uses `-` and `_` in place of `+` and `/`, and often leaves out the `=` padding. JWTs use it. Both kinds decode here, with or without padding.

### Line breaks

Email (MIME) Base64 has a line break at least every 76 characters. Line breaks and spaces are ignored when decoding. An email attachment pasted with its headers (`Content-Type: …`, a blank line, then the Base64) decodes too, and Download keeps its file name.

### Files and images

Open or drop a file up to 5 MB to encode it. A data URL such as `data:image/png;base64,iVBOR…`, or Base64 of an image, decodes to the image with a preview; Download saves it.

### Size

Every 3 bytes become 4 characters, so Base64 is about a third larger than the original.

### Not encryption

Anyone can decode Base64. It makes bytes safe to send as text; it does not hide them.

### In code

Shell `base64 file` and `base64 -d`. Python `base64.b64encode(data)`. JavaScript `btoa` and `atob` work on single bytes only, so encode text to UTF-8 first with `TextEncoder`.

### Open from a link

`?decode=SGVsbG8=` or `?encode=Hello` opens the page with the answer; `?input=` detects the direction. A `+` in a link turns into a space, so write it as `%2B`; spaces in `decode` are read back as `+`.

Runs in the browser; nothing is uploaded. Part of toolkitnow.org.
