Skip to main content
SiteIndex
DeveloperSiap digunakan

Escape atau dekode entitas HTML

Ubah karakter khusus menjadi entitas HTML atau dekode entitas kembali menjadi teks yang terbaca.

Panduan

Area kerja interaktif

Tidak perlu akun
Encoder dan dekoder entitas HTML

51 characters in · 51 characters out — the conversion updates live as you type.

Why escape? The XSS example

Inserted into a page unescaped, this user input would run as code:

<script>alert('XSS')</script>

Escaped, the browser displays it as harmless text instead:

&lt;script&gt;alert(&#039;XSS&#039;)&lt;/script&gt;
Copyable JavaScript snippets
escapeHtml
function escapeHtml(text) {
  return text
    .replace(/&/g, "&amp;")
    .replace(/</g, "&lt;")
    .replace(/>/g, "&gt;")
    .replace(/"/g, "&quot;")
    .replace(/'/g, "&#039;");
}
unescapeHtml
function unescapeHtml(text) {
  const textarea = document.createElement("textarea");
  textarea.innerHTML = text;
  return textarea.value;
}
Entity reference
CharacterNamedDecimalHexDescription
&&amp;&#38;&#x26;Ampersand — always escape this one first, or the other entities break
<&lt;&#60;&#x3C;Less-than sign — starts a tag if left raw
>&gt;&#62;&#x3E;Greater-than sign — closes a tag if left raw
"&quot;&#34;&#x22;Quotation mark — ends a double-quoted attribute value if left raw
'&apos;&#39;&#x27;Apostrophe — ends a single-quoted attribute value (&#039; is the widely compatible form)
␣&nbsp;&#160;&#xA0;Non-breaking space — renders as a space that cannot wrap or collapse
©&copy;&#169;&#xA9;Copyright sign
®&reg;&#174;&#xAE;Registered trademark sign
™&trade;&#8482;&#x2122;Trademark sign
€&euro;&#8364;&#x20AC;Euro sign
Apa itu Encoder dan dekoder entitas HTML?

Ubah karakter khusus menjadi entitas HTML atau dekode entitas kembali menjadi teks yang terbaca.

Cara kerja

Ubah karakter khusus menjadi entitas HTML atau dekode entitas kembali menjadi teks yang terbaca.

Kegunaan umum

Ubah karakter khusus menjadi entitas HTML atau dekode entitas kembali menjadi teks yang terbaca.

Batasan

Hasil dapat bergantung pada browser, jaringan, input, dan layanan eksternal. Alat ini bersifat informatif dan bukan pengganti diagnosis khusus atau saran profesional.

Pertanyaan umum
Apa itu Encoder dan dekoder entitas HTML?
Ubah karakter khusus menjadi entitas HTML atau dekode entitas kembali menjadi teks yang terbaca.

Alat terkait