Text Encoding Converter: HTML Entities, URL Encoding and Base64
Base64, percent-encoding and HTML character references do three different jobs, and picking the wrong one is the usual reason a value arrives broken. Each of the 3 rewrites text so a particular container can carry it, and each container refuses a different set of characters.
Base64 is about bytes rather than characters. Base64 exists to carry data through channels that accept only US-ASCII text. It is an encoding, not encryption: any decoder reverses it. Base64 writes data with 64 characters - A to Z, a to z, 0 to 9, plus (+) and slash (/) - and reserves the equals sign (=) for padding.
Percent-encoding is about URLs. A percent-encoded octet is a triplet: a percent sign followed by the two hexadecimal digits of that byte's value. A URL gives some characters a job — a slash separates path segments, a question mark opens the query — so a value holding one has to say whether it means the job or the character.
HTML character references are about documents. An HTML character reference starts with an ampersand and ends with a semicolon. A named reference uses a name from the HTML standard's table (&); a numeric one uses &# and decimal digits (A) or &#x and hexadecimal digits (A). A browser reads a less-than sign as the start of a tag, so text holding one has to spell it another way.
The pairs below run both ways, and each links the page that shows its working.
Most Popular Text Encoding Tools
- encode a value for a link — the value goes into a link
- clean HTML entities out of pasted text — the text came back full of entities
- decode a Base64 image and download it — the Base64 turns out to be a picture
All Text Encoding Converters
Every converter in the family, grouped as pairs that reverse each other. The set is 8 tools across 10 pages, and each row runs one direction of one scheme. The From and To columns name the value you have and the value you want, so the row you need is the one whose From column already matches what is in front of you. Nothing here is a shortlist: this is the whole family, and any pair not in the table is a pair this site does not run.
| From | To | Tool |
|---|---|---|
| text | Base64 | Base64 Encode |
| Base64 | text | Base64 Decode |
| text | percent-encoding | URL Encode |
| percent-encoding | text | URL Decode |
| text | HTML entities | HTML Encode |
| HTML entities | text | HTML Decode |
| an image file | a Base64 data URI | Image to Base64 |
| a Base64 data URI | an image file | Base64 to Image |
Which Converter Do I Need?
Is the value going into a link?
Then it is percent-encoding you want. A query-string value carries characters the URL itself uses as punctuation, and each one has to be written as a triplet before it goes in: encode a value for a link.
Is it going into a page?
Then it is a character reference. Markup reads a less-than sign and an ampersand as syntax, so a value carrying either has to be escaped first: HTML Encode.
Is it a file rather than text?
Then it is Base64, and usually a data URI. A file has no characters to speak of, only bytes, and Base64 is the scheme that carries bytes through something that only accepts text: Image to Base64.
Is this binary code rather than an encoding?
If what you hold is 0s and 1s, none of the three is the tool. That is a different family: if the input is 0s and 1s, read a string of 0s and 1s back as text.
Conversion Tables
Each scheme's table lives on the page that owns it, reads either way round, and carries a row id you can link to.
- The 64-character alphabet, index by index: Base64 Encode.
- The reserved and unreserved sets with every triplet: URL Decode.
- The named and numeric forms of each reference: clean HTML entities out of pasted text.
How Text Encoding Works
Every one of these schemes replaces characters a container will not carry with characters it will, and every one of them is reversible without anything travelling alongside the result.
- Base64 regroups bits: three bytes are read as twenty-four bits and written as four characters of six.
- Percent-encoding substitutes octets: every byte outside the unreserved set becomes a percent sign and two hexadecimal digits.
- A character reference substitutes one character: an ampersand opens it, a semicolon closes it, and a name or a number sits between.
The page for each direction shows the working on a real value.
Guides
- URL, HTML and Base64 encoding compared — the three schemes side by side
FAQs About Text Encoding
Which encoding do you need: URL, HTML or Base64?
The container decides: a link takes percent-encoding, a document takes character references, and a file takes Base64.
What is an encoder decoder tool?
A pair of pages that run one scheme both ways, so a value you encode here comes back unchanged on the page beside it.
Is URL encoding the same as HTML encoding?
No. They protect different containers and give different output for the same character.
Which converter handles an image rather than text?
The two data URI pages: one reads a file and writes the string, the other reverses it.
Why did my text come back with & in it?
Because it was escaped and never decoded. An HTML character reference starts with an ampersand and ends with a semicolon. A named reference uses a name from the HTML standard's table (&); a numeric one uses &# and decimal digits (A) or &#x and hexadecimal digits (A).