Escape text for HTML contexts
Encode sets plain text on a temporary textarea and reads innerHTML, producing entities such as < for <. Decode assigns entity markup to innerHTML and reads the decoded value back. Processing stays in your browser tab.
Not a full HTML sanitizer
This does not strip scripts or allowlisted tags for untrusted user HTML. Use it for escaping snippets you plan to embed as text, not for cleaning arbitrary markup from the web.
Questions
Does encode handle non-breaking spaces?
Browser encoding may emit numeric or named entities depending on the character. For Markdown output, see the Markdown to HTML converter instead.
Can decode fix double-encoded ampersands?
Run decode once per encoding layer. Repeated decode on &lt; may need two passes depending on how the string was stored.