🔒 Processed locally in your browser — no data uploaded
← Back to Home

HTML Entity Encoder / Decoder

Input text
Result

What the HTML Entity Encoder / Decoder does

This page converts reserved characters in a block of text into HTML entities, and converts entities back into the characters they stand for. Encoding turns the ampersand, the less-than sign and the greater-than sign into &, < and >, which is what makes a code sample display as readable text instead of being parsed as markup. Decoding walks the same path in reverse.

The box loads with a sample line that shows a div tag, a copyright entity and escaped brackets. Press the encode button and that line becomes literal entity text, ready to paste into a documentation page where the tag has to appear as words on screen. Paste an entity back in and press decode, and the copyright symbol returns as a character while the surrounding tags are read as markup.

How to use it

  1. Paste your textDrop the markup or the entity string into the single input box. It starts with a small sample so you can test both directions before you commit your own content to it.
  2. Press encode or decodeEncode escapes the characters HTML reserves, so the result displays as written. Decode resolves named and numeric entities such as & or © back into the symbols they represent.
  3. Read the output boxThe converted string appears under the buttons and can be selected and copied as ordinary text. The counter beneath it reports the length after conversion, which grows during an encode pass and shrinks during a decode.
  4. Clear between jobsEmpty both boxes before pasting the next string. The page holds no history, and the previous result is replaced the moment you run the tool again, so copy anything you want to keep first.

Options and formats

Encode directionEscaping covers the ampersand, the angle brackets and non-breaking spaces. Single and double quotes are left as they are, so an encode pass does not prepare text for use inside a quoted HTML attribute.
Decode directionNamed entities, decimal references such as © and hexadecimal ones such as © all resolve to their characters. A sequence that is not a valid entity passes through untouched rather than raising an error.
Mixed inputBoth buttons accept text that already contains entities. Encoding a string a second time turns the ampersand of & into &, so run each direction once and inspect the result rather than stacking passes.
Length counterIt reports characters after conversion, not before. Encoding always adds characters rather than saving space, and a short tag can grow noticeably once its symbols are written out in full.

Things to watch out for

Quotes stay unescapedThe encoder leaves quotation marks alone because they only matter inside attribute values. If you are assembling an attribute by hand, wrap the value yourself and use your template language to escape the quotes.
Decode parses markupThe decode side hands your text to the browser's HTML parser to resolve entities. Tags in the box are treated as tags, so they disappear from the result, and image tags can fire a network request. Do not paste markup you do not trust.
Escaping twiceEncoding an already encoded string converts every ampersand, so & becomes & and renders as visible entity text. If the output shows entities inside entities, you ran one pass more than the page needed.
Not a sanitiserEncoding characters and filtering hostile HTML are different jobs. This page will turn a script tag into harmless text, but it cannot tell you whether a string is safe to insert into a live page with other context around it.

Frequently asked questions

Why does my HTML show up as text instead of rendering?

The tags were encoded somewhere along the way. Once angle brackets become < and >, the browser treats them as characters to print rather than markup to build. Decode the string if you wanted live HTML, or keep it encoded when the point is to show the code to a reader.

Can I use this to protect against XSS?

It covers one step only. Escaping user text before placing it in HTML is correct, but safety also depends on where the text lands. Values inside attributes, inside URLs and inside script blocks each need their own escaping rules, and this page has no context-aware mode.

Which characters does the encoder turn into entities?

The ampersand, the less-than sign, the greater-than sign and non-breaking spaces. Accented letters, currency signs, copyright marks and emoji stay as ordinary characters, so a string containing a copyright symbol keeps that symbol rather than an entity written out in text.

What is the difference between & and &?

The second one has been escaped twice. & is the entity for an ampersand and renders as a single character, while & renders as the visible characters of the entity itself. If your page shows entity text instead of a symbol, run one decode pass over it.

Does it understand numeric character references?

Yes, decoding resolves both decimal and hexadecimal references into their characters. Encoding never writes numeric references, so a decode followed by an encode does not reproduce the original string character for character. Keep the source text if you need an exact round trip.

Is there a size limit on the input?

The page enforces none, but everything runs in a single browser tab, so a very long document will slow the tab down and may stall the parser. For bulk work, split the text into chunks or move the escaping step into your build script instead.