ToolMill.io

HTML Entity Encode / Decode — Escape & Unescape HTML

HTML Entity Encode / Decode converts special characters like <, >, &, and quotes into safe HTML entities (and decodes them back). Use it when working with HTML attributes, templates, CMS editors, Markdown docs, or when debugging copy/paste issues. Handles common named entities (e.g. &lt;, &gt;, &amp;, &quot;) and numeric entities. Runs 100% locally in your browser — no uploads — and works offline after installing ToolMill as a PWA.

编码

试试看

实例

将 HTML 编码为实体
投入
<div>"x" & y</div>
产出
&lt;div&gt;&quot;x&quot; &amp; y&lt;/div&gt;
解码 HTML 实体
投入
&lt;span title=&quot;Tom &amp; Jerry&quot;&gt;5 &amp;lt; 10&lt;/span&gt;
产出
<span title="Tom & Jerry">5 < 10</span>

何时编码 HTML 实体

使用实体编码时,需要像角括号,安培和等字符,或引文字面显示而不是被解释为标记. 这对教程, CMS 字段, Markdown 文档, 代码样本, 复制片段, 以及 HTML 属性值特别有用 。

什么被编码

The most common cases are <, >, &, and quotes. Depending on the workflow, you may see named entities such as &lt; and &amp;, or numeric forms such as ' and '. Different editors may choose different forms while still rendering the same visible character.

实际工作流程

当您想要在文档中显示原始 HTML 源, 清理从 CMS 或支持系统复制的实体填充文本, 从导出中解码已经脱逃的字符串, 或核实粘贴片段是否在发布前一次或多次脱逃时, 此页面是有用的 。

避免双重编码

A common mistake is encoding text that already contains entities. For example, a plain ampersand becomes &amp;, but an existing &amp; encoded again becomes &amp;amp;. If the pasted input already looks escaped, check it carefully before clicking Encode.

情况仍然重要

实体编码对于在许多内容工作流程中显示字面标记和防止意外渲染很有用,但并不能完全取代每个应用程序中的环境意识逃出. 解码后输出如果粘贴到活的HTML编辑器或页面构建器中,也可以再次成为活性的标记.

隐私和当地处理

在您在网页或种子中重播实体转换文本之前

在发布或嵌入结果之前,确认将使用它的确切的 HTML 上下文,以及目标系统是否已经自动执行逃出. 如果一个正确转换的字符串被插入到错误的地方或两次逃脱,仍然可能是错误的.

HTML 实体转换仍可产生不安全或不想要的结果

实体转换可以帮助显示和逃出,但并不保证每个上下文的安全. 双编码,部分逃出,以及文本内容和属性上下文不匹配,如果目的地期望不同的处理方式,仍然会留下输出中断或误导.

如何解释编码和解码 HTML 实体输出

被编码的输出意在在与HTML相关的上下文中安全地代表字符,而被解码的输出则会还原这些实体所代表的文字字符. 这并不能自动使结果适合您可能粘贴的每一个地方,因为HTML文本节点,属性,脚本,和种子可以各自有不同的逃生需要.

由于转换在浏览器中运行,你可以检查被复制的模板片段,CMS内容,支持消息,或者部分逃出标记而无需将文本发送到另一个站点. 当你的片断包括内部内容或草稿时,这才是实用的。

相关工具