The quick answer

Base64 converts binary data into 64 safe text characters (A–Z, a–z, 0–9, + and /) so it can travel through systems that only handle text: email, JSON, XML, URLs, data attributes. Paste text or a Base64 string above and encode or decode instantly. Everything runs locally in your browser, which makes it safe for tokens, credentials and payloads you wouldn't paste into a random server-side tool.

The cost is size: Base64 makes data about 33% larger (3 bytes become 4 characters). It is an encoding, not encryption: anyone can decode it, so never treat Base64 as a way to hide secrets.

How to encode or decode Base64

  1. Paste your input

    Into the left pane: plain text to encode, or a Base64 string to decode. The Load example link drops in a sample string; the tool handles UTF-8 correctly, so emoji and non-Latin text round-trip: café encodes to Y2Fmw6k=, not mojibake.

  2. Pick the direction

    The Encode / Decode buttons below the panes set the direction, and the output pane updates live as you type, so there is no run button. Decoding an invalid string shows a clear error instead of garbage.

  3. Copy, download or chain

    Copy puts the result on your clipboard, Download saves it as a text file, and Use as input pipes the output back into the input pane; flip the direction and you have a round-trip test.

  4. For data URIs

    Prepend data:image/png;base64, (or the right MIME type) to the encoded string to embed the file directly in HTML or CSS.

How Base64 works, in one minute

The algorithm reads 3 bytes (24 bits) at a time, splits them into four 6-bit groups, and maps each group to its character in the 64-character alphabet. 6 bits hold values 0–63, which is exactly the alphabet size. When the input isn't a multiple of 3 bytes, the output is padded with = characters (one = for 2 leftover bytes, two = for 1). That is why Base64 strings end in = or == as often as not, and why the padding is mandatory, not decorative.

Anatomy of an encoded string

Input

Base64 encoding of the word "Tool"

Output

Input: Tool (4 bytes: 54 6f 6f 6c) → output: VG9vbA==; the == shows the input wasn't a multiple of 3 bytes
Input sizeBase64 sizeOverhead
3 bytes4 chars33.3%
1 KB (1,024 bytes)1,365 chars33.3%
100 KB image≈ 133 KB33%
1 MB file≈ 1.33 MB33%
The 4/3 rule: Base64 always costs about a third more

Two alphabet variants matter in practice. Standard Base64 uses + and /, which break URLs. The URL-safe variant (RFC 4648 §5) swaps them for - and _ and usually drops padding. That is what you'll meet in JWTs (the dots separate header.payload.signature, each segment being URL-safe Base64) and in tokens passed as query parameters.

Where Base64 already runs in your day

You read and produce Base64 more often than you send it. Every email attachment rides through SMTP as MIME Base64 wrapped at 76 characters per line. Every JWT access token is three URL-safe Base64 segments joined by dots; those belong to the URL-Safe Base64 page, because this decoder matches the standard alphabet and rejects the - and _ characters JWTs contain (the JWT Decoder tool handles them end to end). Inline images and fonts in CSS are data URIs with a Base64 body. Source maps end in Base64 VLQ. Even many database drivers accept Base64 blobs for binary columns. The format is infrastructure plumbing, which is exactly why a private, in-browser encoder that never ships your tokens to someone's server is the right default.

The pitfalls that eat an afternoon

  • UTF-8 confusion: encoding Unicode text as raw bytes per-character produces mojibake. Correct round-tripping is UTF-8 encode → Base64. This tool does that automatically.
  • Missing padding: some decoders reject strings without their trailing =; others tolerate it. When in doubt, keep the padding.
  • Newlines in the middle of encoded strings: MIME (email) wraps Base64 at 76 characters per line. This decoder skips whitespace on its own, so pasted email bodies decode here without a cleanup pass.
  • Assuming it's secret: Base64 is trivially reversible. "Encoding" a password or API key in Base64 hides it from glancing eyes only, and it's the first thing every attacker tries.
  • URL contexts: use the URL-safe alphabet (- and _) or percent-encode the + and /, or your token gets truncated at the first slash.
  • Embedding huge files as data URIs: the 33% overhead plus parse cost makes a 2 MB image a 2.7 MB HTML payload. Reserve data URIs for icons and small assets.

Frequently asked questions

Is Base64 encryption?

No. Base64 is a reversible encoding: anyone can decode it instantly. It protects nothing; use it for transport compatibility, and use real encryption (TLS, AES) for secrecy.

Why does Base64 make data 33% larger?

It packs 3 bytes (24 bits) into 4 text characters, each carrying 6 bits; 4 characters × 6 bits over 8-bit bytes gives the 4/3 ≈ 1.33 size ratio.

What do the = signs at the end mean?

Padding. When input length isn't a multiple of 3 bytes, the last group is completed with = (one or two) so decoders can reconstruct the exact byte count.

How do I put an image inside HTML with Base64?

Encode the image file, then use it as a data URI: <img src="data:image/png;base64,…your string…">. Best for small icons and logos; for large images the 33% size penalty usually outweighs saving one request.

What is URL-safe Base64?

The variant from RFC 4648 that replaces + with - and / with _ (and typically omits padding) so the string can sit in URLs and filenames without breaking them; that is the format used inside JWTs.

Is my data uploaded when I use this tool?

No. Encoding and decoding happen in your browser; tokens and payloads never leave your device.

Sources and further reading

Sources and further reading

We cite primary sources (standards bodies, government agencies, official documentation) wherever they exist so you can verify every number on this page yourself.