HTML Entity Encoder / Decoder

Convert reserved HTML characters into safe entities, or decode named and numeric entity references back to text. Everything runs in your browser.

Work in your browser

Local and private

Encode turns < > & " ' into entities; Decode restores them.

How to use HTML Entity Encoder / Decoder

Three simple steps, with your content kept on your device.

01

Paste text

Add the text you want to encode into entities or decode back into characters.

02

Choose a mode

Select Encode for safe embedding or Decode to restore readable text.

03

Copy or download

Grab the converted result or save it as a .txt file.

Built for useful work

Fast, focused, and made to be clear on every screen.

Named entities

Uses readable named entities such as &amp; &lt; &gt; &quot; and &#39;.

Both directions

Encode plain text to entities and decode entities back to text.

100% local

Everything runs in your browser. Nothing is uploaded.

How to encode HTML characters

Paste any text into the input, keep the mode set to Encode, and press Convert. The tool replaces reserved characters such as <, >, &, and quotes with their HTML entity forms, so the output can be embedded in a page without being interpreted as markup.

A practical example: pasting <script>alert(1)</script> produces &lt;script&gt;alert(1)&lt;/script&gt;, which displays as literal text instead of executing. This is exactly what an html entity encoder does for code samples and user input.

The encoded result can be copied directly into an HTML file, a CMS editor, an email template, or a documentation page.

How to decode HTML entities

Switch the mode to Decode and paste text that contains entities such as &amp;lt;, &amp;gt;, &amp;amp;, or numeric forms like &#39;. The tool restores them to the characters they represent, making copied source code readable again.

Decoding is handy when you have markup that was escaped for storage or display and you want the original text back — for example, when extracting content from a page source or an API response.

Because decoding runs locally, you can safely process snippets that might contain sensitive content without sending them anywhere.

Named and numeric entities

The encoder prefers readable named entities — &amp; for ampersand, &lt; for less-than, &gt; for greater-than, &quot; for double quote, and &#39; for apostrophe — because they are easy to recognize in source code.

When a character has no named form, the tool falls back to a numeric entity such as &#169; for the copyright symbol, which every browser supports.

This mix keeps the output valid across all HTML documents while staying as readable as possible.

Encoding text for the web safely

Displaying user-generated content without encoding is one of the most common causes of HTML injection and broken pages. Encoding before output prevents unexpected markup from being rendered.

For developers, an html entity decoder is equally useful when debugging escaped API responses or CMS exports that store content in entity form.

Because the tool runs entirely in the browser, it also works offline and never requires an account.

Related developer tools

This tool fits into the Valestiom developer toolkit. The HTML Formatter beautifies and cleans markup, the JSON Escape / Unescape handles the analogous problem for JSON strings, and the URL Encoder/Decoder does the same for URL-safe encoding.

Together they cover the encoding and escaping needs of everyday web development — all processed locally in your browser.

Input size and how encoding changes length

The text box accepts up to about one megabyte per run, which covers a long template or a sizeable block of user-generated content without noticeable delay.

Encoding always makes text longer, because a single ampersand becomes the five characters of its entity form. The tool measures the projected output before building it and reports a clear message rather than returning a truncated result.

Once a result is ready it can be copied to the clipboard in one click or saved as a plain .txt file when the converted text needs to travel to another program.

How decoding resolves entity references

Decoding is handled by the browser's own HTML parser rather than a hand-written lookup table. That means the tool resolves exactly the same named and numeric references a real page would.

Named forms such as the less-than and ampersand entities, decimal references, and hexadecimal references are therefore all understood without needing to be listed in advance.

A sequence the parser does not recognise as a valid entity is left exactly as it was found, so text that merely resembles an entity survives a decode pass unchanged.

Frequently asked questions

What is an HTML entity?

An HTML entity is a special sequence that starts with &amp; and ends with ;, such as &amp;lt; for the less-than sign. Browsers render it as the character instead of interpreting it as markup.

Which characters get encoded?

The encoder converts the reserved HTML characters — &lt; &gt; &amp; &quot; and &#39; — plus other characters that could be misinterpreted, using their named or numeric entity forms.

Why would I encode text?

Encoding is essential when you want to display code samples, user-generated content, or markup as plain text on a page without it being executed by the browser.