Base64: Conversion, URL-Safe Variant and MIME Line Wrapping

Open Tool Base64 Encoder & Decoder

The problem it solves

Email, JSON and URLs safely carry text only; raw binary breaks them. Base64 maps every 3 bytes onto 4 safe characters from A-Z, a-z, 0-9, + and /, padding the tail with equals signs. Three bytes become four characters, so length grows by 4/3 and an image inlined as a data URI gets noticeably bigger. This is the standard scheme rather than a custom rule of this page.

Steps

  1. Paste into the upper box: plain text to encode, or a Base64 string to decode.
  2. Click Encode (text to Base64) or Decode (Base64 to text) and the result appears below.
  3. For URL parameters or filenames, enable the URL-safe variant, which swaps + for - and / for _ and drops trailing equals.
  4. Line width has three settings: none for JSON and code, 64 for some config files, and 76 (MIME) for mail attachments.
  5. Copy the output when done.

Chinese text, emoji and length

Encoding reads UTF-8 bytes, so one Chinese character takes 3 bytes and becomes 4 Base64 characters, while an emoji usually takes 4 bytes and becomes 6 characters. Total length is always a multiple of 4, padded at the end: one equals sign means one missing byte, two mean two. Those equals signs may be dropped, and the tool will re-add them, but a stripped string may no longer be a multiple of 4 and strict validators will reject it.

Why decoding fails

The usual cause is an incomplete paste, truncated by a chat client or cut at a line break. The second is charset mismatch, feeding URL-safe -_ into a decoder that only accepts +/ . The third is a non-UTF-8 source: GBK text encoded and then decoded still yields GBK bytes, which the browser renders as mojibake until the original encoding is known. A subtler case is double encoding, where one decode strips only one layer and the output still looks like Base64.

⏫︎