HTML Entity Encoder
Encode or decode HTML special characters
HTML Entity Encoder — what it does
Encode text so HTML special characters become safe entities, or decode entities back into readable characters. The four that matter most — the angle brackets, ampersand and quote — are exactly the characters that turn displayed text into parsed markup, which is why encoding them is the foundation of safe HTML output.
Worked example
A line of HTML containing a query string, an apostrophe, straight quotes and accented characters, run through Encode.
Input text
<a href="report.html?dept=sales&year=2026">Tom & Jerry's "Q4" report</a> — café résumé © 2026
Output — encoded
<a href="report.html?dept=sales&year=2026">Tom & Jerry's "Q4" report</a> — café résumé © 2026
Only & < > " and ' are encoded (the apostrophe as '); the em dash, the accented letters and © are left as they are.
When this tool helps
- Showing example HTML on a page as visible code instead of having the browser render it.
- Preparing user-supplied text for insertion into a page without introducing markup.
- Decoding an export where entities like &amp; are showing up literally to readers.
How to use it
- Paste the text or the entity-encoded string.
- Choose encode or decode.
- Review the converted output.
- Copy it into your page or document.
Accuracy, limits, and good practice
- Encode the ampersand first when doing it manually, or you will double-encode every other entity — a mistake this tool avoids by handling order internally.
- Double-encoded text shows &amp; to readers; decoding once restores & and decoding twice restores the original character.
- Entity encoding is for display safety, not security by itself — server-side escaping in the right context is still required for untrusted input.
Frequently asked questions
Which characters must be encoded?
Ampersand, less-than and greater-than always; quotes when the text sits inside an attribute value.
Do I need entities for accented characters?
Not with UTF-8, which every modern page uses. Named entities remain useful for clarity and for invisible characters.
Why does my page show tags as text?
The markup was entity-encoded somewhere in the pipeline. Decode it, or fix the step that encoded content it should have passed through.
Which entities can Decode handle?
Any entity a browser understands: named ones such as € © and —, decimal forms like — and hexadecimal forms like 中. Decoding is done by the browser's own HTML parser, so it goes one level only: &amp; comes back as &, and becomes a real non-breaking space that looks like an ordinary space.
Will Decode strip or alter tags in my text?
No. The text is parsed the way a textarea's content is, so <b> becomes a literal <b> and tags that are already there are kept as text rather than executed or removed; line breaks are kept too.
Related tools on this site
- Character Frequency — Count letters, digits, symbols, and their frequency
- HTML Minifier — Remove comments and unnecessary whitespace from HTML
- Lorem Ipsum Generator — Generate placeholder paragraphs for layouts and documents
Further reading: Cleaning Up Text You Pasted From Somewhere Else
Everything above runs inside this page. HTML Entity Encoder needs no account, no upload, and no server round trip — close the tab and nothing is left behind.
HTML 實體編碼能做什麼
把文字編碼成安全的 HTML 實體,或把實體解碼回可讀字元。最關鍵的四個字元——角括號、與號與引號——正是會讓「顯示文字」變成「被解析的標記」的字元,這也是安全輸出 HTML 的基礎。
實際範例
一行含網址參數、撇號、直引號與重音字母的 HTML,按下編碼。
原文
<a href="report.html?dept=sales&year=2026">Tom & Jerry's "Q4" report</a> — café résumé © 2026
編碼後
<a href="report.html?dept=sales&year=2026">Tom & Jerry's "Q4" report</a> — café résumé © 2026
只有 & < > " 與 ' 會被編碼(撇號變成 ');破折號、重音字母與 © 原樣保留。
什麼時候用得上
- 在頁面上以可見程式碼展示 HTML 範例,而不是讓瀏覽器直接渲染。
- 把使用者提供的文字處理成可安全插入頁面、不會夾帶標記的內容。
- 解碼那些讓讀者看到 &amp; 這種字樣的匯出內容。
使用步驟
- 貼上文字或實體編碼字串。
- 選擇編碼或解碼。
- 檢視轉換結果。
- 複製到你的頁面或文件中。
精確度、限制與實務建議
- 手動處理時要先編碼與號,否則其他實體都會被二次編碼——本工具內部已處理好順序。
- 被二次編碼的文字會顯示成 &amp;;解碼一次得到 &,解碼兩次才回到原字元。
- 實體編碼確保顯示安全,本身不等於資安措施——不可信輸入仍需在正確情境做伺服器端逸出。
常見問題
哪些字元一定要編碼?
與號、小於與大於一律要;文字位於屬性值內時,引號也要。
重音字元需要用實體嗎?
使用 UTF-8(現代頁面皆是)就不需要。具名實體仍適合用於清晰表達與不可見字元。
為什麼我的頁面把標籤顯示成文字?
內容在流程中某處被實體編碼了。請解碼,或修正那個不該編碼卻編碼的環節。
解碼支援哪些實體?
瀏覽器看得懂的都行:€ © — 這類具名實體、— 這類十進位寫法,以及 中 這類十六進位寫法。解碼交給瀏覽器自己的 HTML 解析器,所以一次只解一層:&amp; 會變成 &,而 會變成看起來像普通空格的不斷行空格。
解碼會拿掉或改動文字裡的標籤嗎?
不會。文字是以 textarea 內容的方式解析,所以 <b> 會變成字面上的 <b>,原本就存在的標籤也以文字保留,不會被執行或拿掉;換行同樣保留。
本站相關工具
- 字元頻率統計 — 統計字母、數字、符號及出現次數
- HTML 壓縮工具 — 移除 HTML 註解與多餘空白
- Lorem Ipsum 產生器 — 為版面與文件產生佔位段落
延伸閱讀: 清理從別處貼上的文字
以上步驟全部在這個頁面內完成,HTML 實體編碼 不需要註冊、不上傳檔案、也不經過伺服器,關閉分頁後不會留下任何資料。