Base64 encoder & decoder

Convert text and files to Base64 and back – including accents and emoji, as base64url or as a ready-made data URI for CSS and HTML.
  • Free
  • No sign-up
  • Your data stays on your device

Your text and files are processed only in your browser and are never uploaded.


Result


            

            
        

How it works

  1. Choose a mode

    Encode text or a whole file – or paste Base64 to make it readable again or save it as a file.

  2. Check the input

    Invalid characters, missing padding or truncated strings are flagged with clear explanations.

  3. Use the result

    Copy the result, grab the ready-made data URI for CSS or HTML, or download the decoded file.

What is Base64 and what is it used for?

Base64 represents any sequence of bytes using just 64 safe characters: A–Z, a–z, 0–9, + and /, plus = as padding at the end. This lets you carry binary data such as images or PDFs through channels that were designed for text:

  • Email attachments (MIME), with a line break after 76 characters
  • Files or keys inside JSON and XML
  • Data URIs that embed images or fonts directly in CSS or HTML
  • HTTP Basic Auth: Authorization: Basic followed by user:password in Base64
  • JSON Web Tokens (JWT), whose parts are base64url-encoded

Every 3 bytes become 4 characters, so the result is about 33% larger than the original, a little more with line breaks.

Keep in mind: Base64 is not encryption. Anyone can turn it back into the original without a key. Passwords or credentials in Base64 are just as readable as plain text.

Standard Base64 or base64url?

Standard Base64 as defined in RFC 4648 uses + and /. Both have a special meaning in URLs and file names, so the base64url variant replaces them with - and _; all other characters stay the same.

Padding with = fills the result up to a multiple of 4 characters. With base64url it's usually left out, for example in JWTs. The text can still be decoded unambiguously without it, but some libraries insist on it. This tool detects both variants when decoding and adds missing padding.

When data URIs make sense

A data URI such as data:image/png;base64,iVBORw0… saves a separate request to the server. That pays off for very small files like icons or placeholders of a few kilobytes.

For larger images the downsides win: the file grows by a third, the browser can't cache it separately, and every change to the image also changes the CSS or HTML file. SVG graphics are often shorter as a URL-encoded data URI without Base64.

Common mistakes

  • btoa() with accented characters: JavaScript's btoa() only accepts characters up to U+00FF and throws an error on emoji or characters like €. Encode the text as UTF-8 with TextEncoder first.
  • Garbled text after decoding: “ä” turns into “ä” when UTF-8 bytes are read as Latin-1, for example with atob().
  • Line breaks and spaces: they easily sneak in when copying from emails. Many decoders ignore them, strict validators don't.
  • Missing padding: passing base64url without = to a standard decoder sometimes fails.
  • Double encoding: if the result looks like Base64 again, the text was probably encoded twice. Decode it a second time.

Frequently asked questions

Is Base64 encryption?

No. Base64 is just a different way of writing the same data, and anyone can reverse it without a key. For confidential data you need real encryption, such as AES, or TLS in transit.

Why does a file get bigger with Base64?

Base64 spreads every 3 bytes across 4 characters, each carrying only 6 bits. That increases the size by about a third, slightly more with MIME line breaks.

What's the difference between Base64 and base64url?

base64url replaces + with - and / with _, so the result fits into URLs and file names without further encoding. The = padding is usually left out.

How do I embed an image as a data URI?

Convert the image in the “File → Base64” tab and use the data URI as the source, for example <img src="data:image/png;base64,…" alt=""> or in CSS with url("data:image/png;base64,…"). This is only worth it for very small images.

What does the = at the end mean?

The equals sign is padding that fills the result up to a multiple of 4 characters. One = means the last group holds only 2 bytes, two == mean it holds 1 byte.

Why do I see strange characters after decoding?

Either UTF-8 text was read with the wrong character set, or the data isn't text at all but, say, an image or a PDF. This tool checks for that automatically and then offers a hex view and a download as a file.

Guides on this topic

Related tools