& HTML Entity Encoder / Decoder
Encode text to HTML entities and decode HTML entities back to readable text. Supports named, decimal, and hex entities. Free online HTML entity encoder and decoder.
Input
Output
How to Use
1
Paste your text
Paste HTML, code, or any text containing characters you want to encode or entity codes you want to decode.
2
Choose mode
Select Encode (text → entities) or Decode (entities → text). Toggle "Non-ASCII only" for partial encoding.
3
Copy the result
The output updates instantly. Click Copy to clipboard to use in your project.
Frequently Asked Questions
What are HTML entities?
HTML entities are codes used to represent characters that have special meaning in HTML, or characters that are difficult to type. For example, < becomes <, > becomes >, & becomes &, and © becomes ©. They prevent browsers from misinterpreting content as markup.
What is the difference between named and numeric entities?
Named entities use descriptive names (&, ©, ®). Numeric decimal entities use the character's Unicode code point (&#38; for &). Numeric hex entities use the hex form (&). All three represent the same characters; named is most readable, numeric works for any character.
What does "encode only non-ASCII" mean?
When enabled, only characters outside the standard ASCII range (above code point 127) are encoded. ASCII-safe HTML characters like < > & are left as-is. Useful when you want to safely include international text in HTML without encoding every character.
When should I encode HTML entities?
Always encode user-generated content before inserting it into HTML to prevent XSS attacks. Encode characters in HTML attributes, especially those that accept URLs. Encode < > & " in any text that will be rendered inside HTML tags.
Is my text sent to a server?
No. All encoding and decoding runs entirely in your browser using JavaScript. Your text never leaves your device.
完整指南:HTML实体编码/解码工具
什么是HTML实体?
HTML实体表示特殊字符:<→<,&→&。三种格式:命名(©)、十进制(©)、十六进制(©)。
如何使用
- 粘贴含特殊字符的文本。
- 选择模式:编码或解码。
- 复制结果用于HTML。
专业技巧
- 在HTML中插入用户内容时始终编码
<、>、&、"以防止XSS。 - 使用UTF-8编码时,大多数Unicode字符不需要编码为实体。
- 在带引号的HTML属性中尤为重要。