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

0 characters
0 characters

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

Last checked by the TextEditor.com team

Encoding is not encryption

Encoding writes the same text with other characters, so it can travel where some characters are not allowed. A web address can't hold a space. An email once could hold only ASCII. Anyone can decode it again, with no key or password. Base64 hides nothing. To keep a secret, you need encryption, and a strong password to go with it.

Your text in every format
FormatResultUsed for
Base64Q2Fmw6kg8J+YgA==Email attachments, data URLs, tokens
Base64URLQ2Fmw6kg8J-YgAWeb addresses and JSON Web Tokens
URL encodingCaf%C3%A9%20%F0%9F%98%80Values in a web address
Form dataCaf%C3%A9+%F0%9F%98%80What a web form sends
HTML entitiesCafé 😀Text inside a web page
JavaScript escapesCaf\u00E9 \uD83D\uDE00Strings in code and JSON
Hex bytes43 61 66 C3 A9 20 F0 9F 98 80Debugging, network tools
Quoted-printableCaf=C3=A9 =F0=9F=98=80Email text
ROT13Pnsé 😀Hiding spoilers and puzzle answers

How UTF-8 turns letters into bytes

Computers store bytes, numbers from 0 to 255. Base64, URL encoding, hex, binary and quoted-printable start by turning your text into bytes with UTF-8, the encoding used by almost every web page. Each character has a number in Unicode, its code point. UTF-8 writes that number in 1 to 4 bytes.

The first bits of each byte say how it is used. A byte that starts with 0 is a whole character from ASCII. A byte that starts with 110, 1110 or 11110 starts a character of 2, 3 or 4 bytes. Every byte that starts with 10 continues one. The rest of the bits, in black below, are the code point in binary.

Type anything and see its bytes
CharacterCode pointBytesBits (marker bits in color)Hex
HU+004810100100048
éU+00E921100001110101001C3 A9
€U+20AC3111000101000001010101100E2 82 AC
😀U+1F600411110000100111111001100010000000F0 9F 98 80

4 characters, 10 bytes. In UTF-16, the way JavaScript counts, the same text is 5 units long.

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

That is why "Read bytes as" matters when you decode. The same bytes read as Windows-1252 turn é into é. If you see text like that, the bytes were right, but they were read with the wrong character set.

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 first 3 bytes of your text, cut into 6 bit groups

Bytes01001000 11000011 10101001

6 bit groups010010 001100 001110 101001

Numbers18 12 14 41

Base64SMOp

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. It turns é into "6Q==", which is not UTF-8, and it fails on € and every emoji. This tool encodes the text as UTF-8 first, so every character comes back the same after decoding.

Advertisement

URL encoding: encodeURIComponent, encodeURI and form data

A web address uses some characters to mark its parts. The ? starts the query, & splits values, # 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.

JavaScript has two functions for it. Use encodeURIComponent for one value, like a search word. Use encodeURI for a whole address you already built, because it keeps the characters that give it shape. Web forms send data a third way: a space becomes +. Email and SMS QR codes use the same percent encoding. The QR code generator adds it for you.

How each mode treats these characters
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. Form data here follows URLSearchParams in your browser.

When you decode form data, turn on the form mode, or every + stays a plus sign. A % that is not followed by two hex digits is an error. The tool shows where it is.

HTML entities: named or numeric?

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. This is also the first step against code injection in web forms.

Other characters need no entity on a page saved as UTF-8. Entities still help when you can't type a character or want to see it in the source, like &nbsp; for a no-break space. HTML has 2,125 named entities. A numeric one, like &#233; or &#xE9;, works for every character, even those with no name.

Unicode escapes in code

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

One character in every language
JavaScript, JSON, Java, C#\uD83D\uDE00
Modern JavaScript\u{1F600}
Python, C, C++\U0001F600
CSS\1F600
HTML&#x1F600;
Code pointU+1F600

In CSS, an escape ends at the first character that is not a hex digit. If a digit or a letter from A to F comes next, put a space after the escape. The space is eaten by the escape and does not show. To look up any character by name, use the character list.

Hex, binary, ROT13, quoted-printable and Punycode

Hex and binary show the UTF-8 bytes as numbers. Hex writes each byte as two digits from 0 to F. Binary writes eight 0s and 1s. Programmers use hex to see what a file really holds. The ASCII table lists the first 128 values in all three forms. To see each letter over its own bits, or 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 hides spoilers from a quick glance, and nothing more. ROT47 does the same with digits and signs.

Quoted-printable is the email format for text that is mostly ASCII. Plain letters stay, and other bytes become = and two hex digits. Lines are kept to 76 characters or fewer, and an = at the end of a line means it goes on. 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, which is what your browser looks up. It also helps you spot fakes. The address аpple.com with a Cyrillic а becomes xn--pple-43d.com, which shows at once that it is not the real one.

Which encoding do I have?

The tool guesses for you when you paste. These are the clues it looks for.

You seeIt is probably
SGVsbG8gd29ybGQ=Base64: letters, digits, + and /, length a multiple of 4, maybe = at the end
eyJhbGciOi...A JSON Web Token: three Base64URL parts split by dots, the first starting with eyJ
Hello%20world%21URL encoding: % and two hex digits
&lt;b&gt; &#233;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 also 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.

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. 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. encodeURI keeps those characters, so use it only for a whole address that is already put together.

Should a space be %20 or + in a URL?

In the path and in most places, use %20. A + means a space only in form data, the part after ? that a web form sends. When in doubt, %20 is the safe choice.

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.

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 spots it and 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 128 ASCII codes 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