HTML Entity Encoder
Escape HTML-sensitive characters.
Read the guideRun the tool
The calculation runs in your browser. This tool does not send your input to JVR Software.
More information
Back to the toolWhat it is and when to use it
HTML Encode prepares arbitrary text to display as characters in an HTML document. It is useful for writing tutorials containing code samples, placing a literal ampersand in text, or turning a string into a value suitable for an ordinary quoted attribute with careful template handling.
How it works
HTML parsers recognise special characters such as the less-than sign, which can begin a tag, and ampersand, which can begin a character reference. Encoding changes those characters into reference syntax, such as < and &. The parser presents the references as text when they appear in the appropriate context.
How to use it
- Paste the raw text you want someone to read.
- Encode it and copy the result to the relevant text context in your document or template.
- Preview the rendered page and confirm that the original characters display visibly and that surrounding markup is intact.
Worked example
The string <strong>Important</strong> becomes <strong>Important</strong>. When a browser reads that result in the text of an HTML element, readers see the angle brackets and the word Important as typed. The raw source retains the character references.
Reading the result
Many ordinary letters and numbers will stay as they are. If the starting string already contains & and you intend it to display as an ampersand, encoding it again will instead produce a representation that displays the literal ampersand reference.
Common mistakes and limits
HTML text encoding is context-specific. JavaScript, CSS and URLs have their own parser rules. Use your template engine’s escaping for normal rendered content, and choose a vetted sanitizer when selectively accepting user-authored HTML. A complete template should account for the surrounding attribute delimiters.
