Skip to content
A minimal html entities decoder/encoder using DOM.
JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
src
test
htmlentities.min.js
readme.md Add a disclaimer

readme.md

htmlentities.js

A minimal html entities decoder/encoder using DOM.

Disclaimer

You shouldn't use this "library" for anything real, this is made purely for demonstrational purposes. For reasons why using the approach may be harmful, see this issue and the article it links to.

Usage

//Encode string
htmlentities.encode('<&>'); // returns '&lt;&amp;&gt;';

//Decode string
htmlentities.decode('&lt;&amp;&gt;'); // returns '<&>';

//Also, htmlentities() is a shorthand for encode
htmlentities === htmlentities.encode; // true

MIT license

Something went wrong with that request. Please try again.