Base64 Encoder / Decoder

Encode text or files to Base64 and decode Base64 back to text or a file. UTF-8, URL-safe, MIME line wrap and data URIs. Private.

Convert text to Base64 and back in one click, or turn any file — an image, a PDF, a font — into Base64 or a ready-to-paste data URI. When you decode, the tool recognises whether the result is text or a file (PNG, JPEG, PDF, ZIP…) and lets you preview or download it.

Text is handled as UTF-8, so accented letters, emoji and scripts such as Hindi or Chinese survive the round trip. Everything happens in your browser; nothing is uploaded.

How to use Base64 Encoder / Decoder

  1. Choose Encode or Decode.
  2. To encode, type or paste text — or pick “File” and choose a file. To decode, paste the Base64 text (a data: URI works too).
  3. Pick options if you need them: URL-safe, line wrapping at 76 characters, or a data: URI for files.
  4. Copy the result or download it. Decoded files can be previewed (images) and downloaded with the right file extension.

Features

  • Text ⇄ Base64 with correct UTF-8 (emoji, accents, any language).
  • URL-safe Base64 (- and _ instead of + and /, no padding) for URLs, JWTs and file names.
  • MIME line wrapping at 76 characters for email and PEM-style output.
  • File to Base64 or data: URI, with an image preview — handy for CSS and HTML.
  • Base64 to file: the type is detected from the content (PNG, JPEG, GIF, WebP, PDF, ZIP, MP3, MP4, SVG…).
  • Tolerant decoding: ignores spaces and line breaks, accepts missing padding and data: prefixes.
  • Clear errors that point to the exact invalid character.
  • Private: files and text never leave your device.

What is Base64?

Base64 is a way to write any data — text or binary files — using only 64 safe characters: A–Z, a–z, 0–9, + and /, with = as padding at the end. Every 3 bytes of data become 4 characters, so Base64 is about 33% larger than the original.

It is used wherever binary data has to travel through systems that only handle text: email attachments (MIME), data URIs in HTML and CSS, JSON APIs, JSON Web Tokens, basic HTTP authentication and certificates (PEM).

Base64 examples

Each group of 3 bytes becomes 4 characters. When the input is not a multiple of 3 bytes, = signs pad the end.

TextBase64Note
ManTWFu3 bytes → 4 characters
MaTWE=one = of padding
MTQ==two = of padding
Hello, world!SGVsbG8sIHdvcmxkIQ==
hélloaMOpbGxvé is 2 bytes in UTF-8
😀8J+YgA==an emoji is 4 bytes

Standard vs URL-safe Base64

Standard Base64 uses + and /, which have special meanings in URLs and file names. URL-safe Base64 (also called base64url, RFC 4648 §5) replaces them with - and _ and usually drops the = padding. JSON Web Tokens use URL-safe Base64. This decoder accepts both automatically.

StandardURL-safe
Characters 62 and 63+ /- _
Padding= at the endusually none
Used inemail, data URIs, PEM, most APIsURLs, JWT, file names, cookies

Base64 is not encryption

Base64 only changes how data is written; anyone can decode it instantly, with no key. Never use it to hide passwords or secrets. To protect data, use real encryption — for example, to protect a PDF with a password, use Protect PDF.

Using images as data URIs

A data URI embeds a file directly in HTML or CSS, such as background-image: url(data:image/png;base64,iVBORw0…). It saves a network request for very small images and icons, but makes the page larger and is not cached separately, so it is best for files of a few kilobytes. Choose File, tick “As data: URI” and copy the result.

Frequently asked questions

Is this Base64 tool free and private?

Yes. It is free with no sign-up, and all encoding and decoding happens in your browser — your text and files are never uploaded.

Why does my decoded text show strange characters?

The text was probably encoded with a different character set (for example Windows-1252 instead of UTF-8), or it is not text at all but a file. This tool decodes text as UTF-8 and detects files automatically.

How do I convert an image to Base64?

Choose Encode, then File, and pick your image. Tick “As data: URI” if you want to paste it straight into HTML or CSS.

How do I turn Base64 back into an image or PDF?

Choose Decode and paste the Base64. The tool recognises images, PDFs and other files, shows a preview for images, and offers “Download file” with the right extension.

What does “not a Base64 character” mean?

The input contains a character that Base64 never uses, such as a quote, comma or an invisible character picked up when copying. The message gives its exact position so you can remove it.

Why is Base64 bigger than the original?

Base64 uses 4 characters for every 3 bytes, so it is about 33% larger (a little more with line breaks). That is the price of making binary data safe to send as text.

Is there a file size limit?

Files up to 200 MB can be encoded. Very large Base64 text may be slow to display on phones.

Related tools