Turn bytes into plain letters and back.

Base64 lets binary data travel through places that only accept plain text: email, JSON, HTML attributes and config files. Paste text or pick a file, and you get a string made only of letters, digits and a few symbols.

It works the other way too. Paste Base64 from an email, an API response or a data URI, and you get the original text back, or a file you can save.

Runs in your browser. Nothing is uploaded.

More developer tools · All 54 tools

How to use it

  1. Type or paste into Input. To convert a file instead, choose it under Encode a file.
  2. Press Encode to get Base64, or Decode to read Base64 you pasted.
  3. Tick URL-safe (Base64url, no padding) for links, file names and tokens, or Wrap lines at 76 characters for email (MIME).
  4. Leave Output as data URI ticked if you want a ready-to-use data: link for a small image or font.
  5. Use Copy output, or Download decoded file when the decoded data is an image, PDF or other binary file. Swap moves the output back into the input.

Good to know

How the encoding works

Base64 (defined in RFC 4648) reads your data three bytes at a time. Those 24 bits are split into four groups of 6 bits, and each group picks one of 64 characters: A–Z, a–z, 0–9, + and /. If the last group is short, = pads it.

length = 4 × ceil(n ÷ 3)

Here n is the number of input bytes. So 300 bytes become exactly 400 characters, a third larger.

A worked example

  • Hi! is 3 bytes and encodes to SGkh, with no padding.
  • Hi is 2 bytes and encodes to SGk=, padded to four characters.
  • é is one letter but 2 bytes in UTF-8, so it becomes w6k=.

Text is always turned into UTF-8 bytes first, so accents, Arabic, Chinese and emoji survive the round trip.

Standard or URL-safe

The standard alphabet uses + and /, which have special meanings in URLs. Base64url (RFC 4648 section 5) swaps them for - and _ and usually drops the padding. The bytes FB FF give +/8= in standard Base64 and -_8 in Base64url. JSON Web Tokens use Base64url.

When decoding, the tool accepts either alphabet, with or without padding, and ignores spaces and line breaks. A leading data:…;base64, prefix is removed for you.

Limits

  • Files must be under 15 MB, because the whole file and its Base64 copy sit in your browser’s memory.
  • Data URIs make pages heavier and cannot be cached on their own, so keep them for small icons and fonts.
  • Line wrapping at 76 characters follows the MIME rules used in email (RFC 2045).

Questions.

Does Base64 keep my data secret?

No. It is a way of writing bytes, not a lock. Anyone can decode it in a second, so never use it to hide a password or key.

Why is the output longer than what I put in?

Every 3 bytes become 4 characters, so the result is about 33% bigger. Line breaks added for email make it slightly bigger again.

The decoded result says it is binary data. What now?

The Base64 held a file, such as an image or PDF, rather than text. Press Download decoded file to save it, then open it with the right app.

Why does decoding fail with an error?

The input has characters outside the Base64 alphabet, padding in the middle, or a length that suggests it was cut off. Check that you copied the whole string.

Is a file I choose uploaded?

No. It is read by your browser on this page and never leaves your device.

When should I use the data URI option?

When you want to paste a small image or font straight into HTML or CSS, for example an icon in an email template. For anything large, a normal file link is better.