How to use Base64 Encode
- 1. Choose what to encode. Text, a dropped file, Basic Auth credentials, hex bytes, PEM keys, or a URL string.
- 2. Pick an output preset. Raw Base64, URL-safe, Data URI, HTML, CSS, Font-face, cURL, JSON, or JSX.
- 3. Copy or download. Everything stays in this tab. Refresh to clear memory.
About this tool
People searching “base64 encode” usually need ASCII-safe bytes for JSON, CSS, or email. Encoding expands size by about 33% and is not encryption — anyone can decode the result.
Text vs files
Short strings belong in the Text module. Images, PDFs, audio, and fonts belong in File mode so you get the correct MIME type and a Data URI ready for HTML or CSS.
URL-safe Base64
Standard Base64 uses `+`, `/`, and `=`. Those break in URLs and filenames. Toggle URL-safe (Base64URL) for JWTs and query parameters — the same RFC 4648 family with a different alphabet.
Code examples
Node
Buffer.from("hello").toString("base64");
Buffer.from(b64, "base64").toString("utf8");Browser (UTF-8 safe)
btoa(unescape(encodeURIComponent(text)));
decodeURIComponent(escape(atob(b64)));Python
import base64
base64.b64encode(b"hello").decode() # aGVsbG8=
base64.b64decode("aGVsbG8=").decode()Data URI
const uri = `data:image/png;base64,${b64}`;
// <img src={uri} /> or CSS url('${uri}')