Base64 Encode — Text to Base64

🔒 Runs in your browser — nothing is sent to a server

Base64 encode any text into a compact ASCII string with one click. Type or paste the plain text below and this tool returns a clean Base64-encoded value ready to drop into JSON payloads, data URIs, `Authorization` headers, email MIME parts or JWT tokens. Full UTF-8 is handled — emoji, accented letters and non-Latin scripts all encode losslessly. Everything runs 100% in your browser: the source text never leaves your device and nothing is uploaded to a server.

Two-pane view: input and output side by side
Copied!

When to Base64 encode text

Base64 encoding of text is the quick fix whenever a string must survive a text-only pipeline without being mangled. Common moments to reach for a Base64 encoder: packaging a secret in a `.env` or Kubernetes Secret, embedding a small font or SVG in a data URI, producing a dummy JWT payload while debugging, transporting pre-formatted email bodies through APIs, or sending a UTF-8 string through legacy systems that only accept ASCII. Running the encode in a trustworthy, offline-first page is the fastest way to generate a value you are about to paste into production code.

How text-to-Base64 encoding works under the hood

Text-to-Base64 encoding is a two-step process. First the input string is converted to its UTF-8 byte sequence — for plain ASCII this is identity, for emoji or accented letters it expands to 2–4 bytes per character. Second, the byte stream is cut into 24-bit groups, each group is split into four 6-bit values, and every value is mapped to a character in the 64-symbol Base64 alphabet. Trailing `=` padding is appended when the final group is shorter than three bytes. This page performs both steps entirely in the browser using the built-in `TextEncoder` and `btoa` APIs.

Examples

Input
Hello, World!
Output
SGVsbG8sIFdvcmxkIQ==
ASCII to Base64 — classic Hello World
Input
base64 encode online
Output
YmFzZTY0IGVuY29kZSBvbmxpbmU=
Base64 encode online — live keyword example

FAQ

How do I encode text to Base64?

Paste your text into the input box above — this tool instantly encodes it as a Base64 string in the output pane. No button press, no upload, no signup. Programmatically, use `btoa()` in the browser for ASCII, `Buffer.from(str, "utf-8").toString("base64")` in Node.js, or `base64.b64encode(str.encode("utf-8")).decode()` in Python.

What is Base64 encoding used for?

Base64 encoding is used anywhere binary or non-ASCII text must travel through text-only channels. Typical use cases: embedding small assets directly in HTML/CSS via data URIs, transporting payloads inside JSON or XML APIs, email MIME bodies, JWT tokens, basic HTTP auth headers and storing encoded configuration values in Kubernetes Secrets or `.env` entries.

How to encode Base64 in different languages?

In JavaScript, call `btoa()` on a binary string; for Unicode wrap the text with `TextEncoder` first. In Node.js use `Buffer.from(str, "utf-8").toString("base64")`. In Python call `base64.b64encode(s.encode("utf-8"))`. In Java use `Base64.getEncoder().encodeToString(bytes)`. In Go use `base64.StdEncoding.EncodeToString(bytes)`. This page follows the same UTF-8 path as the Node.js snippet.

Does Base64 encoding compress or encrypt my text?

Neither. Base64 encoding is a transport wrapper, not compression or encryption. The output is actually about 33% larger than the input because every three input bytes become four ASCII characters. Base64 is trivially reversible by anyone, so never treat it as a security layer — use AES or HTTPS for confidentiality and gzip/Brotli for size.

Is this Base64 encoder safe for sensitive data?

Yes. This Base64 encoder runs entirely in your browser using the native `TextEncoder` and `btoa` APIs. Your plain text and the Base64 output stay on your machine — nothing is uploaded, no server-side logging happens, and there is no account or history. Safe for API keys, tokens and other confidential strings.

How do I produce URL-safe Base64 (base64url)?

This tool outputs classic Base64 using `+`, `/` and `=` characters. To get URL-safe Base64 (RFC 4648 base64url) — the format used by JWT tokens and OAuth state parameters — take the result and replace `+` with `-`, `/` with `_`, and optionally strip trailing `=` padding. The decoded bytes stay the same.

Glossary

Base64

A binary-to-text encoding scheme that maps groups of three bytes into four ASCII characters from a 64-symbol alphabet (A–Z, a–z, 0–9, +, /). Base64 travels safely through text-only transports — email MIME, JSON and XML payloads, data URIs in HTML/CSS, JWT tokens. The output is roughly 4/3 the size of the input. Base64 is not encryption.

Base64 encoder

Any tool or function that converts bytes to the Base64 ASCII alphabet. A Base64 encoder takes the raw byte representation of a string (usually UTF-8) and emits a compact, copy-paste-friendly ASCII form. This page is a text-oriented Base64 encoder: you give it plain text, it handles the UTF-8 conversion step, then applies the Base64 alphabet in your browser.

UTF-8

The dominant Unicode encoding on the web, representing each character with 1–4 bytes. A robust Base64 encoder does not operate directly on characters — it first converts the string to its UTF-8 byte sequence, then encodes those bytes. This two-step flow is why `btoa` alone fails on emoji and non-Latin scripts; this tool wraps text with `TextEncoder` before calling `btoa`.

Data URI

A compact `data:` URL that embeds small resources inline, using Base64 as the payload format. The pattern is `data:<mime>;base64,<encoded>`. Data URIs are handy for CSS fonts, inline icons, and email signatures where external references are blocked. Because Base64 inflates payload size, data URIs are best used for small assets under a few kilobytes, not large media.

Padding

The `=` characters appended to a Base64 string so its length is a multiple of four. Padding tells the decoder how many bytes the last group represents: one `=` means two real output bytes, two `=` means one, and no `=` means three. URL-safe Base64 often drops padding, but classic Base64 keeps it for clarity.

Related tools