esc

Base64 Encode / Decode

Encode and decode Base64 text or files online, including URL-safe Base64 and MIME line wrapping, entirely in your browser.

Plain text
0 B
Base64
Encoded — in — out —
Guide

What Base64 is — and isn't

Base64 is a way to represent arbitrary binary data using only 64 printable ASCII characters (A–Z, a–z, 0–9, + and / ). This Base64 encoder and decoder groups the input into 3-byte chunks and re-encodes each as four characters, padding the final group with = . It exists so binary can travel safely through text-only channels — email bodies, JSON, data URIs, HTTP headers.

Encoding is not encryption. Base64 is fully reversible by anyone, with no key involved — it adds zero secrecy and grows the payload by about a third. The URL-safe variant swaps +// for -/_ and usually drops padding, so the value survives inside URLs and filenames. Everything here runs in your browser; the text and files you convert never leave your machine.

Examples

Base64 encoding examples

Text is converted to UTF-8 bytes first, then encoded. Some typical results:

Input Bytes Standard Base64 URL-safe
Hi! 3 SGkh SGkh
hello 5 aGVsbG8= aGVsbG8
é 2 w6k= w6k
€ 3 4oKs 4oKs
<<???>> 7 PDw/Pz8+Pg== PDw_Pz8-Pg

Three bytes always become four characters, so Hi! needs no padding, while hello (5 bytes) ends with one =. The accented é is two bytes in UTF-8, which is why it encodes to four characters rather than two. The last row shows the URL-safe alphabet replacing / and + and dropping the padding.

Not a secret: HTTP Basic credentials

Encoding user:pa55word gives dXNlcjpwYTU1d29yZA==, the value sent in an Authorization: Basic header. Switching to Decode reverses it instantly, which is why Basic authentication is only safe over HTTPS.

Results

Reading the Base64 result and status bar

  • Encoded / Decoded — the conversion succeeded. When encoding a file, the verdict includes the file name.
  • Decoded · binary — the bytes are valid Base64 but not valid UTF-8 text (an image, archive or compressed data). The output pane shows the byte count instead of garbled characters; use Download to save the raw bytes.
  • Invalid Base64 — decoding failed; the message names the problem (see troubleshooting below).
  • In / out / ratio — byte sizes before and after, and the change as a percentage. Encoding hello shows 5 B in, 8 B out, +60%; longer inputs approach +33%, plus one byte per line break when Wrap 76 is on. Decoding shows a negative ratio.
  • Download — saves encoded output as encoded.base64.txt (or <file name>.base64.txt for files) and decoded bytes as decoded.bin.
Use cases

When to use Base64 encoding

  • Data URIs. Encode a small icon with the File source, then prepend the prefix yourself, for example data:image/png;base64,, to inline it in HTML or CSS.
  • Config and secrets files. Kubernetes Secret data fields and many CI variables expect Base64; decode them to check what is really stored.
  • API payloads. Put binary data such as a certificate or a small attachment inside JSON, or decode a Base64 field from an API response and inspect it with the JSON Formatter.
  • Tokens and URLs. Use URL-safe output for values placed in query strings or file names. JWT segments are URL-safe Base64 too; the JWT Decoder splits and decodes them for you.
  • Email attachments. Wrap 76 breaks the output into 76-character lines, the line length used for Base64 in MIME email bodies.
Troubleshooting

Troubleshooting Base64 decoding

Symptom Likely cause Fix
“length is not a multiple of 4 (string looks truncated)” Characters were lost when copying Copy the complete value again
“unexpected character … not in the Base64 alphabet” A data:…;base64, prefix, quotes, or URL escapes such as %2B and %3D Remove the prefix and quotes; URL-decode the value first
“Decoded · binary” for something that should be text The text was encoded from a legacy charset such as Latin-1 or Windows-1252, not UTF-8 Download the bytes and open them with the right encoding
Downloaded file will not open Base64 carries no file name or type, so it is saved as decoded.bin Rename it with the right extension, such as .png or .pdf
Output differs from another encoder Different URL-safe, padding or line-wrap settings Match the URL-safe and Wrap 76 toggles to what the other system expects

Spaces and line breaks in pasted Base64 are ignored, missing = padding is added back, and input containing - or _ is treated as URL-safe automatically, so wrapped MIME text and unpadded tokens decode without editing.

Limitations

Base64 tool limitations

  • Text is always encoded as UTF-8, and decoded output is shown as text only when it is valid UTF-8. There is no option for other character sets.
  • Files can be loaded for encoding only; to decode, paste the Base64 text. The tool does not build or strip data: URI prefixes.
  • URL-safe and Wrap 76 apply to encoding. Wrapped lines use a single line feed (LF) and a fixed width of 76 characters.
  • Files are processed in browser memory, so very large files are limited by your device rather than by a server-side cap.
  • The decoder accepts Base64 without padding, so it is more lenient than strict decoders that reject unpadded input. Base64 offers no integrity check — a corrupted but well-formed string decodes to wrong bytes without an error.
FAQ

Frequently asked questions

Is my data uploaded anywhere?

No. Base64 encoding and decoding run entirely client-side using the browser engine. Files are read locally with the FileReader API and are not sent to a server.

Is Base64 a form of encryption?

No. Base64 is encoding, not encryption. There is no key and anyone can decode it instantly, so never use Base64 to hide passwords, API keys or private data.

What does URL-safe Base64 change?

Standard Base64 uses + and /, which can be awkward in URLs and filenames. URL-safe Base64 substitutes - and _ and often omits = padding. This decoder accepts standard and URL-safe variants.

Why did my Base64 decode fail?

The input may contain a non-Base64 character, be truncated, or have invalid padding. Whitespace and line breaks are ignored automatically; if decoded bytes are not UTF-8 text, download the raw bytes instead.

How do I turn Base64 back into a file?

Switch to Decode, paste the Base64 without any data: URI prefix, and click Download. The raw bytes are saved as decoded.bin; rename it with the correct extension, such as .png or .pdf, because Base64 does not store a file name or type.