
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 see | It 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%21 | URL encoding: % and two hex digits |
| <b> é | HTML entities: & and a name or a number, then ; |
| \u00E9 \x41 | Unicode escapes from code |
| 48 65 6C 6C 6F | Hex bytes: pairs of 0 to 9 and A to F |
| Caf=C3=A9 | Quoted-printable: = and two hex digits, = at line ends |
| xn--mnchen-3ya | Punycode: 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 points | Bytes | Bit pattern | Examples |
|---|---|---|---|
| U+0000 to U+007F | 1 | 0xxxxxxx | A to Z, digits, signs |
| U+0080 to U+07FF | 2 | 110xxxxx 10xxxxxx | é, ß, Greek, Cyrillic, Hebrew, Arabic |
| U+0800 to U+FFFF | 3 | 1110xxxx 10xxxxxx 10xxxxxx | €, Chinese, Japanese, Korean, most symbols |
| U+10000 to U+10FFFF | 4 | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx | Emoji, rare scripts, math letters |
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.
| Character | encodeURIComponent | encodeURI | Form 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 &, <, >, " and ', and the browser shows them as text instead of reading them as code. A numeric entity like é or é 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 | 😀 |
| Code point | U+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.