TSToolSeta
Developer Tools · Ready

HTML Entity Encoder

Encode HTML-sensitive characters or decode common entities.

Workbench online
Loading tool controls…

HTML Entity Encoder and Decoder guide

Encode HTML-sensitive characters or decode common named, decimal, and hexadecimal character references locally.

What this tool does

Encode mode replaces five characters that commonly require representation in HTML text: ampersand becomes &, less-than becomes <, greater-than becomes >, double quotation mark becomes ", and apostrophe becomes '. An optional setting converts non-ASCII Unicode code points to decimal numeric references.

Decode mode reverses those common named references and supports decimal forms such as © plus hexadecimal forms such as 🙂. Unknown named entities are left unchanged rather than guessed. This limited, explicit behavior makes the result repeatable but does not attempt to implement the entire HTML named-character-reference catalog.

Entity encoding changes text representation. It is not a complete cross-site scripting defense and is not interchangeable across HTML text, quoted attributes, URLs, JavaScript, CSS, SQL, or template syntax. Secure output handling depends on the destination context and framework.

How to use it

  1. Select encode or decode mode.
  2. Paste the source text.
  3. In encode mode, decide whether non-ASCII characters should become numeric references.
  4. Select the conversion button.
  5. Copy the result and use it only in the context for which it was prepared.

When writing a React or another modern framework application, prefer the framework’s normal text interpolation and escaping rules instead of manually building HTML strings. Avoid unsafe raw-HTML APIs unless content has been sanitized for that exact use.

Benefits

  • Encodes five common HTML-sensitive characters
  • Optionally converts non-ASCII code points numerically
  • Decodes common named plus numeric references
  • Preserves unknown named entities for review
  • Keeps source code and content on the device

Encoding, escaping, and sanitization

Escaping makes data safe for a particular output location by representing special characters. Sanitization parses and removes or allows markup according to a security policy. Validation checks whether input follows expected rules. These operations solve different problems.

Encoding an attacker-controlled string for HTML text does not automatically make the same value safe inside a URL, script, style block, or event handler. Double encoding can also create visible entity text such as < rather than the intended character. Track whether data is raw or already encoded.

Use the XML Formatter to validate and indent a complete XML document. Use the Unicode Escape Converter when you need JavaScript or code-point escape notation rather than HTML character references.

Security notice: Do not rely on this utility alone to secure untrusted HTML. Use maintained framework escaping and a context-appropriate sanitizer or security library.

FAQ

No. Named decoding is intentionally limited to amp, lt, gt, quot, and apos, while decimal and hexadecimal numeric references are supported.

No. Encoding represents special characters for a context; sanitization parses markup and applies an allow-or-remove security policy.

Representing ampersands prevents existing text from accidentally beginning a character reference in the encoded output.

Yes. Valid Unicode decimal and hexadecimal code points up to the Unicode maximum are converted.

No. Encoding and decoding are performed locally by JavaScript in the browser.

Keep working

Related tools

View all Developer Tools