在线 HTML 实体编码/解码,支持命名实体、十进制和十六进制数字实体
HTML entities are a mechanism for representing special characters using special strings in HTML documents. Since HTML uses < and > to define tags, displaying these characters directly on a page would cause the browser to misinterpret them as actual tags. Additionally, & marks the start of an entity and must also be escaped. HTML entity encoding replaces special characters with entity references starting with & and ending with ;, ensuring text is safely and correctly rendered in HTML pages while preventing XSS (Cross-Site Scripting) attacks.
Use predefined mnemonic names to represent special characters. The most commonly used ones include:
| Character | Named Entity | Description |
|---|---|---|
& | & | Ampersand |
< | < | Less than |
> | > | Greater than |
" | " | Double quote |
' | ' | Apostrophe (single quote) |
| | Non-breaking space |
© | © | Copyright symbol |
® | ® | Registered trademark |
Format: &#number;, where the number is the character's Unicode code point in decimal. For example: < represents <, & represents &. This representation can encode any Unicode character, unrestricted by the named entity list.
Format: &#xhex-digits;, e.g. < represents <, 你 represents the Chinese character "你". The hexadecimal form is more common in web development because it aligns with the standard Unicode code point notation (U+XXXX), making it easier to reference and use.
< and > must be encoded; otherwise, the browser will render the code content as actual HTML elements.<script>alert("XSS")</script>, after encoding it becomes <script>alert("XSS")</script>, which the browser displays as plain text instead of executing it.Compared to manually replacing characters one by one or memorizing all entity names, our online HTML Entity Encoder/Decoder provides an intuitive two-panel interface — encode on the left, decode on the right — with all operations performed locally in your browser. No software installation required and no data is ever uploaded to any server. Easily toggle between "encode only special characters" and "encode all characters" modes to suit different scenarios. The real-time preview lets you see results as you type, plus Ctrl+Enter shortcut and copy buttons greatly boost your development efficiency. Whether you're a frontend developer writing code examples, a security engineer testing XSS protection, or a content editor handling special characters, this is your go-to tool.