Base64 Encode & Decode

Encode any text to Base64 or decode Base64 back to text, correctly handling accents, emoji and non-Latin scripts through UTF-8. Choose the URL-safe alphabet used in JWTs and URLs, drop the = padding, or wrap lines at 76 characters for email. You can also encode a whole file, and decoded binary data is shown as hex with a download button. All encoding happens in your browser; nothing is uploaded.

Mode

Input

59 characters

or drop it here. It stays on your device.

Output

Base64
SGVsbG8sIHdvcmxkISBHcsO8w59lIGF1cyBCZXJsaW4gwrcgwqFIb2xhLCBNw6l4aWNvISDCtyDQn9GA0LjQstC10YIg8J+Riw==

Checks

  • Info 73 B becomes 100 B. Base64 is about 33% larger than the original.

Runs entirely in your browser. Nothing you paste or open here is uploaded or stored.

How to use the Base64 tool

  1. Choose Encode or Decode.
  2. Type or paste your text, or Base64 to decode. To encode a file, choose it or drop it on the box.
  3. For encoding, pick options: URL-safe alphabet, no padding, or 76-character lines.
  4. Copy or download the result. Decoded binary data has its own download button.

Decoding is tolerant: spaces and line breaks are ignored, padding is optional, and the standard and URL-safe alphabets are both accepted and detected.

How Base64 works

Base64 takes the input bytes three at a time (24 bits) and splits them into four groups of 6 bits. Each 6-bit number (0–63) maps to a character: A–Z, a–z, 0–9, then + and /. When the input length isn’t a multiple of three, the last group is padded with =.

Text has to be turned into bytes first. This tool uses UTF-8, the encoding of almost every website. That’s why it handles “Grüße”, “¡Hola!” and “Привет” correctly, where the browser’s built-in btoa() fails on any character above U+00FF.

Worked examples

Example 1: text with accents and emoji

Encode the sample sentence. Decode the result again and you get the identical text, including the emoji. Each non-ASCII character takes 2–4 UTF-8 bytes, so the Base64 is longer than for plain English.

Example 2: HTTP Basic authentication header

Authorization: Basic headers carry username:password in Base64. Encoding user:pass gives dXNlcjpwYXNz. This shows why Basic auth must only be used over HTTPS: the password can be decoded by anyone who sees the header.

Example 3: a JWT segment

Paste the middle part of a JSON Web Token and decode it. The URL-safe alphabet and missing padding are detected automatically, and the JSON payload appears. For full token inspection, use the JWT decoder.

When to use Base64

  • Embedding small files in JSON, XML or HTML (images as data URIs, certificates in config).
  • Email attachments (MIME uses 76-character lines).
  • Binary data in URLs or cookies, with the URL-safe alphabet.

Avoid it for large files over the network: the 33% overhead adds up, and binary uploads are more efficient.

Common mistakes

  • Treating Base64 as security. It hides nothing. Encrypt sensitive data instead.
  • Mixing alphabets. A server expecting standard Base64 may reject - and _.
  • Double encoding. Encoding an already-encoded string produces valid but useless output; decode once to check.
  • Wrong text encoding. Data encoded from Latin-1 text decodes to garbled characters as UTF-8.

Frequently asked questions

Is Base64 encryption?

No. Base64 is an encoding: it represents bytes using 64 safe characters so binary data can travel through text-only channels. Anyone can decode it instantly, so never use it to hide passwords or secrets.

Why is the Base64 output longer than the input?

Every 3 bytes become 4 characters, so Base64 is about 33% larger than the original, plus padding. That's the price of using only safe text characters.

What is URL-safe Base64?

Standard Base64 uses + and /, which have special meanings in URLs. The URL-safe variant (RFC 4648 section 5) uses - and _ instead and often omits the = padding. It's used in JSON Web Tokens and many APIs.

Why does decoding sometimes produce strange characters?

If the original data was binary (an image or a compressed file), it isn't text. The decoder detects this and shows the bytes as hex with a download button instead.

Can I encode files and images, not just text?

Yes. Base64 works on any bytes, which is how images end up in data URIs. For images, the Image to Base64 tool reads the file directly and builds the data URI for you.

Sources