ToolBit

Base64 Encode and Decode

Encode text to Base64 or decode it back, in your browser.

0 bytes (UTF-8)

0 characters

Runs in your browser. Nothing is uploaded.

Type or paste into either field and the other updates as you type. Text is encoded as UTF-8, so English and other Latin-script text, Cyrillic, every other Unicode script and emoji survive a round trip. Decoding ignores whitespace and line breaks, accepts missing = padding and strips a pasted data:...;base64, prefix.

URL-safe uses the - and _ alphabet of RFC 4648 section 5. Line breaks every 76 chars wraps output like MIME email. To encode a file, press File → data URL or drop it onto the Base64 field. You get a data:<mime>;base64,... string; the data URL prefix checkbox, shown while a file is loaded, switches to bare Base64. Text files also fill the Text field.

Example

Text field: tool bit is fun

dG9vbCBiaXQgaXMgZnVu

The 15 bytes split into five groups of 3, so there is no = padding. Other scripts work the same way: Greek Ελληνικά gives zpXOu867zrfOvc65zrrOrA==, Chinese 你好 gives 5L2g5aW9.

Base64 in code

btoa accepts only Latin-1, so encode to UTF-8 bytes first; then any script works.

const bytes = new TextEncoder().encode("tool bit is fun");
const b64 = btoa(String.fromCharCode(...bytes));
// dG9vbCBiaXQgaXMgZnVu

const text = new TextDecoder().decode(
  Uint8Array.from(atob(b64), (c) => c.charCodeAt(0)),
);
import base64

b64 = base64.b64encode("tool bit is fun".encode("utf-8")).decode("ascii")
text = base64.b64decode(b64).decode("utf-8")

On Linux, GNU base64 wraps at 76 characters unless -w 0 is given; on macOS it does not wrap.

printf 'tool bit is fun' | base64              # dG9vbCBiaXQgaXMgZnVu
printf 'dG9vbCBiaXQgaXMgZnVu' | base64 -d      # tool bit is fun

Limitations

  • Text (as UTF-8), decoded output and files are limited to 1 MB (1,000,000 bytes). Above that the tool shows an error and does not convert.
  • Line breaks are \n, not MIME’s CRLF, with no trailing newline.
  • URL-safe output keeps = padding.
  • Base64 alphabets are strict: - or _ in standard mode, or + or / in URL-safe mode, gives an error with a hint to switch.
  • Data URLs always use the standard alphabet without line breaks; URL-safe and Line breaks affect only bare Base64.
  • Decoding is UTF-8 only. Invalid bytes show as � with a note; there is no other charset and no hex view.

FAQ

Why does Base64 end with = or ==?

Base64 turns 3 bytes into 4 characters. If the length is not a multiple of 3, the last group is padded: f becomes Zg==, fo becomes Zm8=.

Is Base64 encryption?

No. It is a reversible encoding with no key; anyone can decode it. It carries binary data through text-only channels such as JSON or email.

Why does the decoded text look broken?

The tool reads bytes as UTF-8. Text in another encoding, such as Windows-1251, appears as �. The data may also be binary, such as an image.

How much bigger is Base64?

About 33%: 4 characters per 3 bytes, rounded up. Line breaks add one character per 76.

How do I convert more than 1 MB?

Use the command line. To encode a file as one line and decode it back:

  • Linux (GNU coreutils): base64 -w 0 photo.jpg > photo.txt, then base64 -d photo.txt > photo.jpg.
  • macOS: base64 -i photo.jpg -o photo.txt, then base64 -d -i photo.txt -o photo.jpg.

Standard or URL-safe?

Standard uses + and /, which have special meaning in URLs. URL-safe uses - and _, so the value fits a query string or filename unchanged. JWTs also drop the = padding, which this tool keeps; decoding accepts both.