Tech

Base64 Encoder

Convert text to Base64 with UTF-8 support and URL-safe variant. Useful for tokens, data URIs, JSON embeds and HTTP headers. Everything is processed in your browser.

Instant🔒In your browserNo signup
Live

What Base64 is

Base64 is an encoding scheme that represents binary data using 64 printable ASCII characters: A-Z, a-z, 0-9, + and /, plus = as padding. Every 3 bytes (24 bits) map to 4 characters of 6 bits each. The name comes from "base 64": the system uses 64 symbols instead of the 256 possible in raw binary.

It's standardized in RFC 4648. There are variants: standard (with + and /), URL-safe (with - and _) and a few less common ones. Every serious language ships Base64 in its standard library.

When to use Base64

  • Email attachments. SMTP was designed for ASCII text. MIME uses Base64 to embed binaries (PDF, images) in messages.
  • Data URIs. data:image/png;base64,iVBORw0KGgo... embeds small images directly into HTML or CSS.
  • JSON with binary data. JSON only supports text. To send bytes without a multipart endpoint, encode them in Base64.
  • JWT. Header, payload and signature are encoded in URL-safe Base64.
  • Basic Auth. The Authorization: Basic ... header carries username:password in Base64 (not secure: requires HTTPS).
  • Config variables. To store small binaries (SSH keys, certificates) in environment variables or YAML.

The URL-safe variant

In URLs, + and / have special meaning. / separates path segments; + in query strings is interpreted as a space. To avoid escaping, the URL-safe variant replaces them with - and _. It also typically drops the trailing = padding.

This variant is used in JWT, OAuth (PKCE), public API keys and, in general, any token that ends up in a URL.

Size and efficiency

Base64 inflates data by about 33%: every 3 bytes become 4. A 100 KB image becomes 133 KB when Base64-encoded. That's why you should only embed small images as data URIs: for anything larger, serve them as a separate file.

If you need something even more compact, consider Base85 (Ascii85), which encodes 4 bytes in 5 characters (25% overhead). The PDF format uses it for embedded images.

Common Base64 mistakes

  1. Confusing it with encryption. Base64 is readable — anyone can decode it. If you need privacy, encrypt with AES before encoding.
  2. Forgetting UTF-8. For text with accents or emoji, encode to UTF-8 first (which our generator does), never plain ASCII.
  3. Mixing variants. Decoding URL-safe Base64 with a standard decoder fails. Normalize first.
  4. Missing padding. Some decoders require the trailing =. If your string lacks it, add it manually so the length is a multiple of 4.

Privacy of this encoder

Everything is processed in your browser with btoa on top of TextEncoder. No server, no content analytics, no logs. Paste whatever you want: if you close the tab, it goes with you.

FAQ

What is Base64?

An encoding that represents binary using 64 ASCII characters. Used to fit bytes into text-only channels.

Is it encryption?

No. Base64 is just encoding, reversible by anyone. For confidentiality use real encryption (AES, libsodium).

When to use URL-safe?

When the result goes in URLs, headers or filenames. Avoids escaping of + and /.

How much does the text grow?

Roughly 33%: every 3 bytes become 4 characters.

Was this generator useful?