Base64 Encode & Decode

Convert text to Base64 and back. UTF-8 safe, runs in your browser.

–

What is Base64?

Base64 turns bytes into plain ASCII letters, digits, + and / so binary data can travel through text-only systems such as email, JSON or URLs. It is encoding, not encryption — anyone can decode it.

In short

Base64 turns bytes into 64 safe text characters, so every 3 bytes become 4 characters and the result is about a third larger. It is an encoding, not encryption: anyone can decode it, so never use it to hide a password or a secret.

Frequently asked questions

What is URL-safe Base64?

It replaces + and / with - and _ and drops the = padding, so the result is safe inside URLs and file names.

Why does decoding fail?

The text may contain characters outside the Base64 alphabet, be missing characters, or not decode to valid UTF-8 text (for example when it holds a binary file).

Can I encode a file or an image here?

No. This page encodes and decodes text you type or paste. To turn an image into a data URL, use a tool built for files.

Is my text sent anywhere?

No. Encoding and decoding run in the page’s JavaScript on your device, and nothing you paste is uploaded.

Our test: size, non-English text and 1,000 round trips

We encoded sample strings with this page in Chromium 153.0.8010.12, then decoded 1,000 random strings back to check that nothing is lost. The random strings were 1 to 200 characters long and mixed plain ASCII, Korean syllables and emoji, with every second one using the URL-safe option.

InputCharactersUTF-8 bytesBase64 lengthOutput
Hello, world!131320SGVsbG8sIHdvcmxkIQ==
안녕하세요515207JWI64WV7ZWY7IS47JqU
👍🎉28128J+RjfCfjok=
café ☕ 東京91624Y2Fmw6kg4piVIOadseS6rA==
  • Round trips: all 1,000 random strings decoded back exactly, including the URL-safe ones whose padding had been removed.
  • Size: Base64 length depends on bytes, not characters. Five Korean syllables take 15 bytes in UTF-8 and become 20 Base64 characters, the same as the 13-character English greeting.
  • URL-safe option: ??>> becomes Pz8+Pg== normally and Pz8-Pg with the option on: + turns into - and the padding is dropped.
  • Decoding: SGVsbG8=, SGVsbG8 (padding missing) and SGVs bG8= (a space inside) all gave "Hello". SGVsbG8* was rejected as not valid Base64, and so was /w==: it is valid Base64, but the single byte it holds (255) is not valid UTF-8 text, and this page decodes to text only.
  • Speed: 1 MB of plain text encoded in 35 ms and became 1,398,104 characters, the expected one-third growth.
More details

Where you meet Base64

Base64 shows up whenever binary data has to pass through a channel built for text. Email attachments are encoded this way, small images are embedded in web pages as data URLs, and the username and password in HTTP Basic authentication are joined with a colon and sent as Base64. The three dot-separated parts of a JSON Web Token are also Base64-style text, which is why you can paste one part here to read what it contains.

A small example

The word Hello becomes SGVsbG8=. Base64 reads the input three bytes at a time and writes four characters for each group, so the output is about one third longer than the input. When the input length is not a multiple of three, one or two = signs are added at the end as padding, which is why many Base64 strings end with them.

Do not use it to hide things

Base64 is only a different way of writing the same data. Anyone can reverse it in a second, so it must never be used to protect a password or a secret key. If you need secrecy, use real encryption. Use this tool to inspect an encoded value, to prepare text for a system that only accepts ASCII, or to check that two systems encode the same text the same way. Choose the URL-safe option when the result will be placed in a web address or a file name.

How much bigger the result gets

Every three bytes of input become four characters of output, rounded up to a whole group of four. The growth is easy to work out ahead of time:

InputBase64 output
1, 2 or 3 bytes4 characters
10 bytes16 characters
100 bytes136 characters
1,000 bytes1,336 characters
1,000,000 bytes1,333,336 characters

The figures include the = padding; URL-safe output without padding can be one or two characters shorter.

So an image embedded in a page as a data URL costs about a third more than the same image served as a file. Email goes a step further: the MIME standard splits Base64 into lines of at most 76 characters, so a little more is added for the line breaks.

Text, bytes and UTF-8

Base64 encodes bytes, not letters. Before encoding, this page turns your text into bytes using UTF-8, the encoding the web uses almost everywhere. Plain English letters take one byte each, so Hi becomes SGk=. An accented letter takes two bytes in UTF-8, so é becomes w6k=, and a Korean syllable such as 한 takes three bytes and becomes 7ZWc. An older system that stores text as Latin-1 writes é as a single byte, and its Base64 is 6Q== instead. When two programs give different Base64 for what looks like the same text, a different character encoding is usually the reason.

What the decoder accepts

When you decode, spaces and line breaks are ignored, so you can paste Base64 copied from an email source or a wrapped log line. The URL-safe characters - and _ are read as + and /, and missing = padding is added back, so both styles decode without changing a setting. The result has to be readable UTF-8 text. If the Base64 holds a picture, a PDF or other binary data, the page usually shows “Not valid Base64 text.” rather than printing unreadable characters.

More in Text & developer