Skip to content

Encode and decode text

Type on either side and the other side updates. Paste something encoded and the tool tells you what it is.

Encoder and decoder

11 characters, 11 bytes
16 characters, 145% of the text

Ctrl+Enter copies the side you are typing in. Your text stays in this browser and is never uploaded.

File to Base64

Your files stay on this device. Nothing is uploaded.

Advertisement
Plain letters going into a small machine and coming out as a strip of code blocks

Which encoding do I have?

Paste something into either box and the tool guesses the format. These are the clues it looks for, so you can also check by eye.

You seeIt is probably
SGVsbG8gd29ybGQ=Base64: letters, digits, + and /, length a multiple of 4, maybe = at the end
eyJhbGciOi...A JWT: three Base64URL parts split by dots, the first starting with eyJ
Hello%20world%21URL encoding: % and two hex digits
<b> éHTML entities: & and a name or a number, then ;
\u00E9 \x41Unicode escapes from code
48 65 6C 6C 6FHex bytes: pairs of 0 to 9 and A to F
Caf=C3=A9Quoted-printable: = and two hex digits, = at line ends
xn--mnchen-3yaPunycode: a domain part that starts with xn--

Hidden characters can break decoding. A zero width space inside Base64 is not one of its 64 characters, so it gives an error. The invisible character finder shows them and takes them out.

How Base64 works

Base64 takes 3 bytes at a time. That is 24 bits, which it cuts into four groups of 6 bits. Each group is a number from 0 to 63, and each number has a character: A to Z, a to z, 0 to 9, + and /. So 3 bytes become 4 characters, and the result is about a third longer. When the last group has only 1 or 2 bytes, = signs fill the gap.

The rules are in RFC 4648. It also defines Base64URL, which uses - and _ instead of + and /, because those two have a meaning in web addresses. JSON Web Tokens use Base64URL without the = at the end.

In JavaScript, the old btoa() function reads each character as one byte, so it fails on € and every emoji. This tool encodes the text as UTF-8 first, so every character comes back the same.

UTF-8: how letters become bytes

Base64, URL encoding, hex, binary and quoted-printable all work on bytes. So the tool first turns your text into bytes with UTF-8, the encoding of almost every web page. It writes the Unicode number of each character, its code point, in 1 to 4 bytes.

Code pointsBytesBit patternExamples
U+0000 to U+007F10xxxxxxxA to Z, digits, signs
U+0080 to U+07FF2110xxxxx 10xxxxxxé, ß, Greek, Cyrillic, Hebrew, Arabic
U+0800 to U+FFFF31110xxxx 10xxxxxx 10xxxxxx€, Chinese, Japanese, Korean, most symbols
U+10000 to U+10FFFF411110xxx 10xxxxxx 10xxxxxx 10xxxxxxEmoji, rare scripts, math letters
Advertisement

URL encoding: %20 or +?

A web address uses some characters to mark its parts. The ? starts the query, & splits values and # starts the fragment. To put one of them inside a value, write it as % and two hex digits. A character outside ASCII becomes its UTF-8 bytes, so é becomes %C3%A9. A space is %20, except in form data, where it is +. When you decode form data, pick the form mode, or every + stays a plus sign.

CharacterencodeURIComponentencodeURIForm data
Space%20%20+
&%26&%26
=%3D=%3D
?%3F?%3F
/%2F/%2F
#%23#%23
+%2B+%2B
é%C3%A9%C3%A9%C3%A9
~~~%7E
!!!%21
'''%27

Shaded cells stay as they are. Email and SMS links in a QR code use the same percent encoding, and the QR code generator adds it for you.

HTML entities and Unicode escapes

In HTML, five characters can break a page: &, <, > and the two quote marks. Write them as &amp;, &lt;, &gt;, &quot; and &#39;, and the browser shows them as text instead of reading them as code. A numeric entity like &#233; or &#xE9; works for any character, even one with no name.

Program code is often kept in ASCII, so other characters go in as escapes. JavaScript and JSON need two escapes for an emoji, because they count text in UTF-16 units.

Language😀 written as an escape
JavaScript, JSON, Java, C#\uD83D\uDE00
Modern JavaScript\u{1F600}
Python, C, C++\U0001F600
CSS\1F600
HTML&#x1F600;
Code pointU+1F600

In CSS, put a space after an escape when a digit or a letter from A to F comes next. The space does not show. To look up any character by name, use the character list.

Hex, binary, ROT13, quoted-printable and Punycode

Hex writes each UTF-8 byte as two digits from 0 to F, and binary writes it as eight 0s and 1s. The ASCII table lists the first 128 values in both. To read binary with missing spaces or zeros, use the binary translator.

ROT13 moves each letter 13 places in the alphabet. Doing it twice gives back the text, so the same button encodes and decodes. It only hides spoilers from a quick glance.

Quoted-printable is the email format for text that is mostly ASCII. If an email shows =C3=A9 instead of é, paste it here and pick Quoted-printable.

Punycode writes domain names with other letters in ASCII. The name münchen.de becomes xn--mnchen-3ya.de. It also shows fakes: аpple.com with a Cyrillic а becomes xn--pple-43d.com.

Frequently asked questions

How do I decode Base64 to text?

Paste the Base64 in the right box with Base64 selected. The text shows up on the left at once. If it is a file, like an image, you get a download button instead.

Why does my Base64 decode to strange characters?

The bytes were made from text in another character set. If é shows up as é, the bytes are fine but were read the wrong way. Change "Read bytes as", for example to Windows-1252 for old Western text. If you still see junk, the Base64 holds a file, not text.

What is the difference between encodeURI and encodeURIComponent?

encodeURIComponent encodes everything that has a meaning in a web address, like / ? & and =. Use it for one value, like a search word. encodeURI keeps those characters, so use it only for a whole address that is already put together.

Is Base64 encryption?

No. Anyone can decode Base64 without a key. It only makes bytes safe to send as text. Never use it to hide a password or other secrets. For that you need real encryption and a strong password.

How do I turn an image into a Base64 data URL?

Drop the image on "File to Base64" under the tool. You get a data URL to copy, ready for an HTML img tag or a CSS background. The file is read in your browser and is not uploaded.

Can I decode a JWT here?

Yes. Paste the token in the right box. The tool shows the header and the payload as JSON. It does not check the signature, so it can't tell you if the token is real.

  • Code editorWrite or paste HTML, CSS, JavaScript, JSON, Python, SQL and more with colors, line numbers and a format button.
  • JSON editorPaste JSON to format, minify or check it.
  • HTML editorWrite in a visual editor and get clean HTML code.
  • ASCII tableAll 256 ASCII codes, the 128 standard ones and extended ASCII, with decimal, hex, octal, binary and HTML values.
  • Invisible characterCopy an invisible character or blank space for empty names and messages.
  • Password generatorMake strong random passwords and easy to type passphrases in your own browser.

↑ ↓ to choose, Enter to open, Esc to close