Encode / Decode
HTML Encode / Decode
Turn ampersands, angle brackets, quotes, and apostrophes into HTML entities, or turn those entities back into text. A short named-entity list is decoded too.
Ready to run.
Encoded HTML
—
Output actions
Ready to copy output once your result appears.
Five characters out, a short list back
HTML Encode / Decode escapes five characters, or reverses a small set of entities. Encode starts selected. It replaces ampersand, less-than, greater-than, double quote, and apostrophe. Decode restores those, plus decimal numeric references and seven named entities. It does not parse a document, and it does not understand hexadecimal references.
How to encode or decode HTML
- 1Leave Encode selected, or press Decode. The field label switches between HTML to encode and Encoded HTML to decode. Switching does not rerun the text already in the field.
- 2Paste, then press Run. Encode writes Encoded successfully. Decode writes Decoded successfully. The result label is Encoded HTML or Decoded HTML. An empty field succeeds with an empty result.
- 3Press Copy output for that result. There is no download. Run again after you change mode or text. The previous result stays until you do.
What it is good for
- • Escaping a snippet so brackets and quotes are safe to show as text.
- • Reversing the entities this page writes, including ' for an apostrophe.
- • Decoding a handful of named entities such as nbsp, mdash, and copy.
Example
Input
<p>Hello & welcome</p>
Output
<p>Hello & welcome</p>
Encode mode, then Run. The ampersand is escaped first, so the entities just written are not escaped a second time on that same click. Tom's "book" becomes Tom's "book".
Which characters encode
Encode walks five replacements in order. Ampersand becomes &. Less-than becomes <. Greater-than becomes >. A double quote becomes ". An apostrophe becomes ', not '. Other characters stay, including é, letters outside Latin script, and existing digits. <p>Hello & welcome</p> becomes <p>Hello & welcome</p>. Because ampersand is first, a second pass over that result turns the leading ampersands of those entities into & as well, so < becomes &lt;. One click does not do that second pass. Pasting the encoded result and clicking Encode again does.
The status line is Encoded successfully. even when the field had none of the five characters. There is no error tone on this tool. The result can be identical to the input, and the click is still a success. Copy output copies the result, including an empty string's failure to copy: an empty success leaves the copy control with nothing to take.
What decode recognizes
Decode replaces the lowercase forms &, <, >, and ", then ', then a decimal numeric reference &#digits;, then a named entity whose name is letters. The named map has only nbsp, copy, reg, trade, mdash, ndash, and hellip. Those seven match in any letter case, so &NBSP; becomes the no-break space and © becomes ©. & must be lowercase to be restored, because that replacement is exact. & is not in the seven names, so it is left as &. < is left as < for the same reason.
& becomes an ampersand through the decimal step. & is not a decimal reference, and hex is not rewritten, so & stays on the page. ' is not one of the seven names and it is not ', so a pasted ' stays '. The apostrophe this page writes on encode is ', and decode turns that back into an apostrophe. Named entities outside the seven, such as € or •, stay as typed. There is no HTML parser and no correction of a missing semicolon.
Jobs for escaped markup
Encode when you are about to drop a snippet into a page that should show the tags rather than render them. The brackets become entities and the browser, later, will show them as brackets. This page does not render a preview. Decode when you copied entities out of source and want the characters back, within the list above. Indenting a document is the HTML beautifier. Stripping tags down to visible words is HTML to text. Writing Markdown and wanting tags is Markdown to HTML. None of those share this entity list.
Percent-encoding for a query string is URL encode / decode, where a space becomes %20. A space on this page stays a space. Standard Base64 of the letters is Base64 encode / decode. A backslash escape for a JSON string is the string escape tool, not an HTML entity. Do not send " here if you wanted a JSON backslash quote. Encode will turn the ampersand into &quot;.
Mode switches and a second pass
The group is labeled HTML encode/decode mode and holds Encode and Decode. Encode is pressed at open. The buttons change labels and which function the next Run calls. They do not clear the field and they do not clear Encoded HTML or Decoded HTML. If you encode, switch to Decode, and forget to press Run, the panel still shows the entities.
Order on decode means a numeric reference is handled before the named pass, so ' is already an apostrophe and is not looked up as a name. A name that is not in the seven is returned unchanged, which is why unknown entities survive. The page never emits ', , or a hex reference. If you need in the output, type the no-break space or the entity yourself. Encode will not invent it from a normal space.
Rules and limitations
Encode replaces & < > " and ' with & < > " and ', in that order. Other characters are unchanged. A second encode escapes the ampersands of the entities.
Decode restores lowercase & < > ", the sequence ', decimal &#digits;, and the names nbsp, copy, reg, trade, mdash, ndash, and hellip. Hex references and ' stay. Mode changes do not rerun. There is no download.
Common problems
If & or < survived, decode only treats the lowercase forms of those four entities. Retype them in lowercase, or encode was not the source of that text.
If a second Encode turned < into &lt;, you ran encode on text that was already encoded. Decode once to go back, instead of encoding again.
Frequently asked questions
Which characters does encode change?
Ampersand, less-than, greater-than, double quote, and apostrophe. Apostrophe becomes '. Accented letters and ordinary spaces stay as they are.
Does decode accept every named entity?
No. The names are nbsp, copy, reg, trade, mdash, ndash, and hellip, in any letter case. € and ' are left unchanged. & < > and " must be lowercase.
Will & become an ampersand?
No. Only decimal numeric references are converted. & becomes an ampersand. & is copied through.
Does switching to Decode rerun the field?
No. Encode and Decode only choose the next Run. The result panel keeps the previous text until you press Run again.
Is my input uploaded or saved?
This tool processes input in your browser and does not save its input or output to local storage. Copy and download are user actions. The site uses analytics for page and action metadata and may use ads and production error reporting; see the Privacy Policy for those services.
About this tool
Maintained by Toolbench. For large or deeply nested files, split the input into smaller batches and verify representative results before using them in an import or application. Report reproducible problems through Contact.
Next steps
Related tools
Continue the workflow with nearby tools for formatting, publishing, debugging, or follow-up checks.
HTML Beautifier
Reindent HTML with 2 spaces, 4 spaces, or a tab.
Open HTML BeautifierHTML to Plain Text
Extract plain text from HTML, with paragraph breaks and link handling.
Open HTML to Plain TextURL Encode / Decode
Percent-encode or decode text with encodeURIComponent.
Open URL Encode / DecodeMarkdown to HTML
Turn Markdown into HTML as you type, with an optional rendered preview.
Open Markdown to HTMLTrust
Policies, contact, and answers
Clear pages for how Toolbench works, what we collect, and how to reach us.