HTML Encoder & Decoder
Encode < > & to entities or decode. ENT_QUOTES, UTF-8, HTML5. Swap, auto-detect, byte stats.
Input Plain HTML
Output Encoded
Options
HTML Entity Reference (Click to expand)
Common Entities
| Character | Entity | Numeric |
|---|---|---|
< | < | < |
> | > | > |
& | & | & |
" | " | " |
' | ' | ' |
space | | |
© | © | © |
® | ® | ® |
™ | ™ | ™ |
When to Use
- Encode Display HTML as text, prevent XSS, or embed in attributes
- Decode Convert entities back to readable HTML or text
What is HTML Encoder & Decoder?
HTML Encoder & Decoder is a free online tool that converts HTML special characters to their entity equivalents (encoding) or converts HTML entities back to plain characters (decoding). Encoding is useful when you need to display HTML as text, prevent cross-site scripting (XSS), or safely embed HTML in attributes. Decoding reverses the process when you have entity-encoded text and need readable HTML or plain text. The tool supports encode and decode modes, multiple quote styles, character sets, and HTML versions. No account or signup is required.
The tool offers two modes selected via radio buttons: Encode and Decode. In encode mode, you paste plain HTML or text and get entity-encoded output (e.g., < becomes &lt;). In decode mode, you paste encoded text and get the original characters. Options include quote style (ENT_QUOTES, ENT_COMPAT, ENT_NOQUOTES), character set (UTF-8, ISO-8859-1), and HTML version (HTML5, HTML 4.01, XHTML). An auto-convert checkbox processes input as you type. A Detect button can auto-detect whether input is encoded or plain. Conversion statistics show input/output bytes and size change. A swap button exchanges input and output. An HTML entity reference table is included for quick lookup.
Who Benefits from This Tool
Web developers benefit when building dynamic content or handling user input. Encoding user-supplied HTML before display prevents XSS. Decoding is needed when reading stored or API data that uses entities. The quote style and charset options match PHP's htmlspecialchars and html_entity_decode, so the tool is useful for testing or generating output that will be used in PHP applications.
Content editors and technical writers benefit when preparing documentation or tutorials. Showing HTML code in a page requires encoding so the browser does not interpret it. The tool makes it easy to convert snippets. Decoding helps when copying encoded content from sources and needing the raw form.
Security researchers and QA engineers benefit when testing input validation. Encoding and decoding are core to safe HTML handling. The tool supports different entity sets (HTML5, HTML4, XHTML) for testing compatibility.
Key Features
Encode and Decode Modes
Switch between encode and decode with radio buttons. Encode converts < > & " ' and other characters to entities. Decode converts entities back to characters. The interface updates labels and placeholders accordingly.
Quote Style
ENT_QUOTES encodes both single and double quotes. ENT_COMPAT encodes only double quotes. ENT_NOQUOTES encodes neither. This matches PHP's htmlspecialchars flags.
Character Set and HTML Version
UTF-8 and ISO-8859-1 are supported. HTML5, HTML 4.01, and XHTML determine which entity set is used. Numeric entities (e.g., <) and named entities (e.g., <) are produced as appropriate.
Auto-Convert and Detect
Enable auto-convert to process input on change. The Detect button attempts to determine if input is encoded or plain and can switch modes. Swap exchanges input and output values.
Conversion Statistics
After conversion, stats show input bytes, output bytes, size change, change percentage, and character counts. Useful for understanding encoding overhead.
Entity Reference Table
A collapsible section lists common entities (e.g., <, >, &) with character and numeric forms. Helps when manually constructing or verifying entities.
How to Use
- Select mode. Choose Encode or Decode via the radio buttons.
- Enter input. Paste your HTML or encoded text into the input textarea. Use Detect if you are unsure which mode to use.
- Adjust options. Set quote style, charset, and HTML version if needed. Defaults work for most cases.
- Convert. With auto-convert on, output updates as you type. Otherwise click the Encode or Decode button. Complete captcha if required.
- Copy or swap. Use the copy button to copy output. Use swap to move output to input for further processing.
Common Use Cases
- Encoding user-generated HTML before display to prevent XSS
- Decoding entity-encoded content from APIs or databases
- Preparing HTML code snippets for documentation or tutorials
- Testing different quote styles and charsets for PHP compatibility
- Converting special characters for use in HTML attributes
- Verifying entity encoding for email or RSS content
Tips & Best Practices
For XSS prevention, encode all user-controlled output that is inserted into HTML. Use ENT_QUOTES when the output may appear in attributes. UTF-8 is the preferred charset for modern applications. Test with sample inputs that include quotes, angle brackets, and ampersands to ensure correct behavior.
When decoding, ensure the input is valid. Malformed entities may not decode correctly. The tool processes in one pass; for nested or complex cases, you may need multiple encode/decode cycles or manual correction.
Limitations & Notes
The tool processes text in the browser or server-side depending on implementation. Very large inputs may be slow. The tool does not parse full HTML documents; it performs character-level encoding and decoding. Entity sets differ between HTML5, HTML4, and XHTML; choose the version that matches your context. The tool does not store your data; process and copy in one session.