Escape text so it can be embedded as a JSON string value, handling control characters and astral code points.
HTML Encoder
Escape text for safe HTML output, encoding the reserved characters or everything non-ASCII.
- Free
- No sign-up
- Runs in your browser
Input
0 characters
Processed entirely in your browser. Nothing is uploaded.
Fill in Input to continue.
Enter your input to see the result
Everything happens on this device. No upload, no account, no network request.
How to use this tool
- 1
Paste your text or encoded data.
- 2
The result appears below. Anything that cannot be handled is reported rather than silently dropped.
Questions about HTML Encoder
Is escaping enough to stop XSS?
In element content and inside a quoted attribute, yes - that is what every template engine does. It is NOT enough inside a `<script>` block, a `<style>` block, an unquoted attribute, or a URL attribute such as `href`, where `javascript:` is still a valid value. Those need context-specific encoding, and this tool cannot know your context. Treat it as a text utility, not a security control.
Is my data sent anywhere?
No. This tool runs as JavaScript inside your browser tab. There is no network request carrying your input, nothing is written to a server log, and it keeps working with your connection switched off. You can confirm it in the browser’s network panel. That matters more here than elsewhere on the site: developer tools handle tokens, keys and production data.
Does the HTML Encoder work offline?
Yes. Once the page has loaded it runs entirely as JavaScript on your own device, so the HTML Encoder keeps working with the network switched off and nothing is ever sent to a server.
Is anything I enter into the HTML Encoder uploaded or stored?
No. The HTML Encoder runs in your browser, so whatever you type or paste never leaves your device — there is no server round-trip, nothing is logged, and there is nothing to delete afterwards.
Can I use the HTML Encoder on a phone or tablet?
Yes. The page is responsive, so the HTML Encoder works the same in a mobile browser as on a desktop, and there is no app to install.
Related tools
Other tools you might reach for next.
Decode an escaped JSON string back to its raw text, with or without the wrapping quotes.
Format and indent JSON, with optional alphabetical key sorting and a precise syntax error when it will not parse.
Percent-encode text for a URL, choosing between component and full-URL escaping.
Decode percent-encoded text, with a specific error when the encoding is malformed.
Decode HTML character references - named, decimal and hexadecimal - back to plain text.
Strip every byte of insignificant whitespace from JSON and report the saving.
Check that JSON is syntactically valid, report its structure, and flag duplicate keys that JSON.parse accepts silently.