Developer Tools

Base64 Encoder / Decoder

Encode text to Base64 or decode Base64 to UTF-8 text with instant live conversion.

Plain text
0 B
Base64

About this tool

Base64 turns arbitrary bytes into plain ASCII text using 64 safe characters (A–Z, a–z, 0–9, + and /). It exists because many systems were designed for text only: email bodies, JSON fields, HTTP headers, URLs and XML cannot carry raw binary safely. Base64 is how images end up inside CSS as data URIs, how credentials travel in HTTP Basic authentication, and how JWTs and many API payloads are packaged.

This tool encodes text (as UTF-8) or any file to Base64, and decodes Base64 back to text or to a downloadable file. It accepts the URL-safe variant, missing padding, line breaks and data: URIs, and it recognizes images, PDFs and archives in decoded data. Everything happens in your browser; files are never uploaded.

How to use Base64 Encoder / Decoder

  1. Choose Encode or Decode. When encoding, pick Text to type or paste, or File to drop any file (up to 25 MB).
  2. For encoding, choose the variant you need: URL-safe replaces + and / with - and _ (required in URLs, filenames and JWTs), Padding adds trailing = signs, and Wrap at 76 inserts line breaks as required by email (MIME).
  3. For files, tick Data URI to get a ready-to-use value such as data:image/png;base64,... for HTML or CSS.
  4. When decoding, paste Base64, Base64URL or a full data: URI. Text is shown directly; binary data is identified, previewed if it is an image, and offered as a download with the right file extension.
  5. Use Swap to move the result to the input and reverse the direction in one click.

Examples

Encode UTF-8 text

Input
héllo 世界
Result
aMOpbGxvIOS4lueVjA==

Non-ASCII characters are first converted to UTF-8 bytes; this is what every modern system expects.

Standard vs. URL-safe

Input
??>
Result
Standard:  Pz8+
URL-safe:  Pz8-

HTTP Basic authentication header

Input
alice:s3cret
Result
Authorization: Basic YWxpY2U6czNjcmV0

Base64 is an encoding, not encryption: anyone can decode this header. Always send it over HTTPS.

How Base64 works

The encoder takes the input three bytes (24 bits) at a time and splits them into four groups of 6 bits. Each 6-bit value (0–63) is mapped to one character of the alphabet. When the input length is not a multiple of three, the last group is completed with zero bits and one or two = signs are added so the output length stays a multiple of four.

Because every 3 bytes become 4 characters, Base64 output is about 33% larger than the original (plus line breaks if wrapped). For that reason it is a poor fit for large files in web pages: a 300 KB image becomes about 400 KB of text that cannot be cached separately.

Common mistakes

  • Treating Base64 as security. It hides nothing; use encryption for secrets.
  • Decoding text with the wrong character set. Text encoded from UTF-8 must be decoded as UTF-8, otherwise accented and CJK characters turn into garbage.
  • Putting standard Base64 in a URL. The characters +, / and = have special meaning in URLs; use the URL-safe variant or percent-encode the value.
  • Copying Base64 with stray characters. Spaces and line breaks are harmless here, but quotes, commas or a truncated end will make decoding fail. The error message shows where.

Frequently asked questions

Everything you need to know about this tool and data security.

What is the difference between Base64 and Base64URL?

Base64URL (RFC 4648 §5) uses - and _ instead of + and /, and usually omits the = padding, so the value can be used in URLs and file names without escaping. JWTs use Base64URL. This tool decodes both automatically.

Why does my decoded text look garbled?

Either the data is binary (an image, a compressed file, encrypted bytes), or the original text was not UTF-8. Binary data is detected and offered as a file download instead of being shown as text.

Can I convert an image to a data URI for CSS or HTML?

Yes. Choose Encode, then File, drop the image and tick Data URI. Paste the result into src="..." or url(...). Keep it to small images such as icons, since data URIs make pages heavier and cannot be cached on their own.

Is there a size limit?

Files up to 25 MB can be encoded. Pasted Base64 is limited only by your browser memory; very long inputs are processed after you stop typing.

Is my data safe when using this tool?

Yes, 100% safe. This tool operates entirely inside your web browser using client-side JavaScript and WebAssembly. Your data never touches any external server.