RevealTheme logo

HTML實體編碼與解碼工具

將特殊字元轉換為HTML實體(&、<等),或進行反向轉換。適用於將文字安全地嵌入HTML。

如何使用本工具

  1. 1

    Pick a mode with the Encode or Decode toggle at the top.

  2. 2

    Paste or type your text into the input box.

  3. 3

    Read the converted result in the output panel below, which updates as you type.

  4. 4

    Select and copy the output to use in your HTML or document.

什麼是HTML實體編碼與解碼工具?

HTML實體是用來表示在HTML中具有特殊含義的字元的跳脫序列:&amp;表示&,&lt;表示<,等等。如果你將使用者提供的文字不經編碼就直接嵌入HTML,就會造成XSS漏洞。本工具可將文字轉換為已編碼實體的HTML以便安全嵌入,或將含有實體的HTML解碼還原為純文字。

常見使用場景

  • Pasting a code snippet into a blog post or docs so tags like <div> display literally instead of rendering.

  • Escaping user-supplied text before dropping it into an HTML template to avoid breaking the markup.

  • Decoding entity-laden strings copied from page source, RSS feeds, or scraped HTML back into readable text.

  • Turning a stray &amp;nbsp; or &amp;mdash; from a CMS export back into a normal space or em dash.

  • Preparing example strings for tutorials where you need to show the raw entity form of a character.

  • Quickly checking what &#39; or &#x2014; decodes to without writing throwaway code.

常見問題

我應該編碼哪些字元?
至少要編碼:< > & " '。它們在HTML中具有特殊含義,可能破壞剖析或造成XSS。
我應該編碼所有實體,還是只編碼不安全的字元?
對於現代的UTF-8頁面,只需編碼不安全的字元(&、<、>、"、')。全部編碼會使HTML體積膨脹。

相關工具