HTML Encoder / Decoder

Convert special characters to HTML entities (<, &, etc.) and back.

Result will appear here.

πŸ“– How to Use

1
Enter Text

Type or paste text containing HTML special characters.

2
Encode or Decode

Click πŸ”Ό HTML Encode to convert <, >, & to entities, or πŸ”½ HTML Decode to revert them.

3
Copy Result

Click πŸ“‹ Copy to save the encoded/decoded HTML to your clipboard.

πŸ’‘ Tip: HTML encoding is essential for preventing XSS attacks and safely displaying user input on web pages.

About the HTML Encoder / Decoder

HTML reserves a few characters for its own syntax — <, >, &, and the quote characters — so any that appear in your content must be written as character entity references rather than literally. The HTML Encoder does that translation in both directions: encoding replaces reserved characters with entities so the browser renders them as visible text, and decoding reverses entities back to the original characters. It is the standard primitive for safely embedding user-provided strings in an HTML document.

How it works

Entities come in two families. Named entities use a readable name wrapped in & and ;: &lt; renders <, &gt; renders >, &amp; renders &, &quot; renders ", and &apos; renders '. Numeric entities reference the Unicode code point directly — decimal &#60; or hexadecimal &#x3C; — and can express any code point. Both families decode to the same character.

Encoding matters because the parser is greedy: seeing <script> it tries to build an element, and seeing a bare & it starts looking for an entity name. Escaping those bytes forces the browser to treat them as text. That is also why encoding is the first line of defense against XSS (Cross-Site Scripting): if attacker-controlled input is reflected into HTML with <, >, and " escaped, a payload like <script>alert(1)</script> renders as inert text rather than executing. Decoding reverses the process by scanning for &name; / &#NN; / &#xHH; patterns and substituting the matching character, so the round-trip is lossless.

Common use cases

  • Safely displaying user comments or form input in an HTML page
  • Showing a code snippet with HTML tags without it being parsed
  • Preparing sample markup for a tutorial or docs page
  • Hardening a template against reflected and stored XSS
  • Decoding scraped text that arrives full of entities

Worked example

Take a snippet with a script tag and an ampersand:

<script>alert("a & b")</script>

After encoding it becomes entities that the browser will render as text instead of executing:

&lt;script&gt;alert(&quot;a &amp; b&quot;)&lt;/script&gt;

Decoding that output returns the original snippet exactly, because every entity maps back to one character.

Frequently asked questions

Which characters should be encoded?

In body content the four essential characters are < (less-than), > (greater-than), & (ampersand), and " (double quote). In attribute values you should also escape the quote character that wraps the value (" or '). Encoding these prevents the browser from treating user text as live HTML markup.

What is the difference between named and numeric entities?

A named entity uses a readable name such as &lt; or &amp;. A numeric entity references the Unicode code point directly, either in decimal (&#60;) or in hexadecimal (&#x3C;). They resolve to the same character; named entities are easier to read while numeric entities can represent any code point that has no name.

Does HTML encoding prevent XSS?

Yes, for content reflected into HTML text or attributes. Escaping <, >, and " stops the browser from parsing attacker-supplied <script> tags as real elements, so the payload renders as inert text instead of executing. This is context-dependent output encoding, which is the primary defense against reflected and stored XSS.

Why does my encoded text look the same after decoding?

Because decoding is the exact inverse of encoding. The decoder walks the string, finds entities such as &lt; or &#60;, and replaces each with the character it stands for, returning the original text. Encoding then escaping that text again yields the same entities, so round-tripping is lossless.

Is my text uploaded anywhere?

No. Encoding and decoding run entirely in your browser through string replacement. Nothing is sent to a server, so the tool is safe for templates, source code, and sensitive content.

HTML 인코더/λ””μ½”λ”λž€?

HTML은 일뢀 문자λ₯Ό 자체 λ¬Έλ²•μš©μœΌλ‘œ μ˜ˆμ•½ν•΄ λ‘‘λ‹ˆλ‹€ — <, >, &, λ”°μ˜΄ν‘œ λ¬Έμžκ°€ κ·Έκ²ƒμž…λ‹ˆλ‹€. κ·Έλž˜μ„œ μ½˜ν…μΈ  μ•ˆμ— 이런 λ¬Έμžκ°€ λ‚˜μ˜€λ©΄ κΈ€μž κ·ΈλŒ€λ‘œκ°€ μ•„λ‹ˆλΌ 문자 μ—”ν„°ν‹° μ°Έμ‘°(character entity reference)둜 써야 ν•©λ‹ˆλ‹€. HTML μΈμ½”λ”λŠ” 이 λ³€ν™˜μ„ μ–‘λ°©ν–₯으둜 μˆ˜ν–‰ν•©λ‹ˆλ‹€. 인코딩은 μ˜ˆμ•½ 문자λ₯Ό μ—”ν„°ν‹°λ‘œ λ°”κΎΈμ–΄ λΈŒλΌμš°μ €κ°€ 이λ₯Ό λ³΄μ΄λŠ” ν…μŠ€νŠΈλ‘œ λ Œλ”λ§ν•˜κ²Œ λ§Œλ“€κ³ , 디코딩은 μ—”ν„°ν‹°λ₯Ό μ›λž˜ 문자둜 λ˜λŒλ¦½λ‹ˆλ‹€. μ‚¬μš©μžκ°€ μ œκ³΅ν•œ λ¬Έμžμ—΄μ„ HTML λ¬Έμ„œμ— μ•ˆμ „ν•˜κ²Œ λΌμ›Œ 넣을 λ•Œ μ“°λŠ” ν‘œμ€€ ν”„λ¦¬λ―Έν‹°λΈŒμž…λ‹ˆλ‹€.

μž‘λ™ 방식

μ—”ν„°ν‹°μ—λŠ” 두 κ°€μ§€ 계열이 μžˆμŠ΅λ‹ˆλ‹€. 이름 μ—”ν„°ν‹°(named entity)λŠ” &와 ;둜 감싼 읽기 μ‰¬μš΄ 이름을 μ”λ‹ˆλ‹€. &lt;λŠ” <, &gt;λŠ” >, &amp;λŠ” &, &quot;λŠ” ", &apos;λŠ” '둜 λ Œλ”λ§λ©λ‹ˆλ‹€. 숫자 μ—”ν„°ν‹°(numeric entity)λŠ” μœ λ‹ˆμ½”λ“œ μ½”λ“œ 포인트λ₯Ό 직접 μ°Έμ‘°ν•©λ‹ˆλ‹€ — μ‹­μ§„ &#60; λ˜λŠ” μ‹­μœ‘μ§„ &#x3C; — 이름이 μ—†λŠ” μ–΄λ–€ μ½”λ“œ ν¬μΈνŠΈλΌλ„ ν‘œν˜„ν•  수 μžˆμŠ΅λ‹ˆλ‹€. 두 계열 λͺ¨λ‘ 같은 문자둜 λ””μ½”λ”©λ©λ‹ˆλ‹€.

인코딩이 μ€‘μš”ν•œ μ΄μœ λŠ” νŒŒμ„œκ°€ νƒμš•μ μ΄κΈ° λ•Œλ¬Έμž…λ‹ˆλ‹€. <script>λ₯Ό 보면 μš”μ†Œλ₯Ό λ§Œλ“€λ € ν•˜κ³ , κ·Έλƒ₯ &λ₯Ό 보면 μ—”ν„°ν‹° 이름을 μ°ΎκΈ° μ‹œμž‘ν•©λ‹ˆλ‹€. 이 λ°”μ΄νŠΈλ“€μ„ μ΄μŠ€μΌ€μ΄ν”„ν•˜λ©΄ λΈŒλΌμš°μ €κ°€ 이λ₯Ό ν…μŠ€νŠΈλ‘œ μ·¨κΈ‰ν•˜κ²Œ λ§Œλ“­λ‹ˆλ‹€. κ·Έλž˜μ„œ 인코딩이 XSS(크둜슀 μ‚¬μ΄νŠΈ μŠ€ν¬λ¦½νŒ…) λ°©μ–΄μ˜ 첫 번째 λ°©νŒ¨μ΄κΈ°λ„ ν•©λ‹ˆλ‹€. κ³΅κ²©μžκ°€ μ œμ–΄ν•œ μž…λ ₯이 <, >, "λ₯Ό μ΄μŠ€μΌ€μ΄ν”„ν•œ 채 HTML둜 좜λ ₯되면, <script>alert(1)</script> 같은 νŽ˜μ΄λ‘œλ“œλŠ” μ‹€ν–‰λ˜μ§€ μ•Šκ³  λ¬΄νš¨ν•œ ν…μŠ€νŠΈλ‘œ λ Œλ”λ§λ©λ‹ˆλ‹€. 디코딩은 μ—­λ°©ν–₯으둜, &name; / &#NN; / &#xHH; νŒ¨ν„΄μ„ μŠ€μΊ”ν•΄ λŒ€μ‘ 문자둜 μΉ˜ν™˜ν•˜λ―€λ‘œ 왕볡이 λ¬΄μ†μ‹€μž…λ‹ˆλ‹€.

자주 μ“°λŠ” 경우

  • μ‚¬μš©μž λŒ“κΈ€μ΄λ‚˜ 폼 μž…λ ₯을 HTML νŽ˜μ΄μ§€μ— μ•ˆμ „ν•˜κ²Œ ν‘œμ‹œν•˜κΈ°
  • HTML νƒœκ·Έλ₯Ό ν¬ν•¨ν•œ μ½”λ“œ 쑰각이 νŒŒμ‹±λ˜μ§€ μ•Šκ³  보이게 좜λ ₯ν•˜κΈ°
  • νŠœν† λ¦¬μ–Ό/λ¬Έμ„œ νŽ˜μ΄μ§€μš© μƒ˜ν”Œ λ§ˆν¬μ—… μ€€λΉ„
  • λ°˜μ‚¬ν˜•/μ €μž₯ν˜• XSS에 λŒ€ν•œ ν…œν”Œλ¦Ώ λ°©μ–΄ κ°•ν™”
  • μ—”ν„°ν‹° νˆ¬μ„±μ΄λ‘œ μˆ˜μ§‘/μ €μž₯된 ν…μŠ€νŠΈ λ””μ½”λ”©

μ‚¬μš© 예

script νƒœκ·Έμ™€ μ•°νΌμƒŒλ“œκ°€ ν¬ν•¨λœ 쑰각을 예둜 λ“­λ‹ˆλ‹€.

<script>alert("a & b")</script>

HTML 인코딩을 거치면 λΈŒλΌμš°μ €κ°€ μ‹€ν–‰ λŒ€μ‹  ν…μŠ€νŠΈλ‘œ λ Œλ”λ§ν•˜λŠ” μ—”ν„°ν‹° λ¬Έμžμ—΄μ΄ λ©λ‹ˆλ‹€.

&lt;script&gt;alert(&quot;a &amp; b&quot;)&lt;/script&gt;

이 좜λ ₯을 λ””μ½”λ”©ν•˜λ©΄ μ›λž˜ 쑰각이 κ·ΈλŒ€λ‘œ λŒμ•„μ˜΅λ‹ˆλ‹€. λͺ¨λ“  μ—”ν„°ν‹°κ°€ ν•œ λ¬Έμžμ— λ§€ν•‘λ˜λ―€λ‘œ λ”ν•΄μ§€κ±°λ‚˜ μžƒνžˆλŠ” 것은 μ—†μŠ΅λ‹ˆλ‹€.

자주 λ¬»λŠ” 질문

μ–΄λ–€ 문자λ₯Ό 인코딩해야 ν•˜λ‚˜μš”?

λ³Έλ¬Έ μ½˜ν…μΈ μ—μ„œ ν•„μˆ˜μ μΈ λ„€ λ¬ΈμžλŠ” <(보닀 μž‘μŒ), >(보닀 큼), &(μ•°νΌμƒŒλ“œ), "(ν°λ”°μ˜΄ν‘œ)μž…λ‹ˆλ‹€. μ†μ„±κ°’μ—μ„œλŠ” 값을 감싼 λ”°μ˜΄ν‘œ 문자(" λ˜λŠ” ')도 μ΄μŠ€μΌ€μ΄ν”„ν•΄μ•Ό ν•©λ‹ˆλ‹€. 이 λ¬Έμžλ“€μ„ μΈμ½”λ”©ν•˜λ©΄ λΈŒλΌμš°μ €κ°€ μ‚¬μš©μž ν…μŠ€νŠΈλ₯Ό μ‚΄μ•„ μžˆλŠ” HTML λ§ˆν¬μ—…μœΌλ‘œ μ·¨κΈ‰ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.

이름 엔터티와 숫자 μ—”ν„°ν‹°μ˜ μ°¨μ΄λŠ”?

이름 μ—”ν„°ν‹°λŠ” &lt;, &amp;처럼 읽기 μ‰¬μš΄ 이름을 μ”λ‹ˆλ‹€. 숫자 μ—”ν„°ν‹°λŠ” μœ λ‹ˆμ½”λ“œ μ½”λ“œ 포인트λ₯Ό 직접 μ°Έμ‘°ν•˜λ©°, μ‹­μ§„(&#60;) λ˜λŠ” μ‹­μœ‘μ§„(&#x3C;) ν˜•μ‹μ΄ μžˆμŠ΅λ‹ˆλ‹€. λ‘˜μ€ 같은 문자둜 ν•΄μ„λ©λ‹ˆλ‹€. 이름 μ—”ν„°ν‹°κ°€ 읽기 νŽΈν•˜κ³ , 숫자 μ—”ν„°ν‹°λŠ” 이름이 μ—†λŠ” λͺ¨λ“  μ½”λ“œ 포인트λ₯Ό ν‘œν˜„ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

HTML 인코딩이 XSSλ₯Ό λ§‰λ‚˜μš”?

λ„€, HTML ν…μŠ€νŠΈλ‚˜ μ†μ„±μœΌλ‘œ 좜λ ₯λ˜λŠ” μ½˜ν…μΈ μ— ν•œν•΄μ„œ κ·Έλ ‡μŠ΅λ‹ˆλ‹€. <, >, "λ₯Ό μ΄μŠ€μΌ€μ΄ν”„ν•˜λ©΄ λΈŒλΌμš°μ €κ°€ κ³΅κ²©μžκ°€ 넣은 <script> νƒœκ·Έλ₯Ό μ‹€μ œ μš”μ†Œλ‘œ νŒŒμ‹±ν•˜μ§€ λͺ»ν•˜λ―€λ‘œ, νŽ˜μ΄λ‘œλ“œκ°€ μ‹€ν–‰λ˜λŠ” λŒ€μ‹  λ¬΄νš¨ν•œ ν…μŠ€νŠΈλ‘œ λ Œλ”λ§λ©λ‹ˆλ‹€. 이것이 λ¬Έλ§₯에 λ”°λ₯Έ 좜λ ₯ μ΄μŠ€μΌ€μ΄ν”„μ΄λ©°, λ°˜μ‚¬ν˜•/μ €μž₯ν˜• XSS에 λŒ€ν•œ 1μ°¨ λ°©μ–΄ μˆ˜λ‹¨μž…λ‹ˆλ‹€.

μΈμ½”λ”©ν•œ ν…μŠ€νŠΈλ₯Ό λ””μ½”λ”©ν•˜λ©΄ μ™œ κ°™μ•„ λ³΄μ΄λ‚˜μš”?

디코딩이 μΈμ½”λ”©μ˜ μ •ν™•ν•œ 역이기 λ•Œλ¬Έμž…λ‹ˆλ‹€. λ””μ½”λ”λŠ” λ¬Έμžμ—΄μ„ ν›‘μœΌλ©° &lt;λ‚˜ &#60; 같은 μ—”ν„°ν‹°λ₯Ό μ°Ύμ•„ 각각이 κ°€λ¦¬ν‚€λŠ” 문자둜 μΉ˜ν™˜ν•΄ μ›λž˜ ν…μŠ€νŠΈλ₯Ό λŒλ €μ€λ‹ˆλ‹€. 이 ν…μŠ€νŠΈλ₯Ό λ‹€μ‹œ μΈμ½”λ”©ν•˜λ©΄ 같은 μ—”ν„°ν‹°κ°€ λ‚˜μ˜€λ―€λ‘œ 왕볡이 λ¬΄μ†μ‹€μž…λ‹ˆλ‹€.

제 ν…μŠ€νŠΈκ°€ μ™ΈλΆ€λ‘œ μ „μ†‘λ˜λ‚˜μš”?

μ•„λ‹™λ‹ˆλ‹€. 인코딩과 디코딩은 μ „μ μœΌλ‘œ λΈŒλΌμš°μ € μ•ˆμ—μ„œ λ¬Έμžμ—΄ μΉ˜ν™˜μœΌλ‘œ μ΄λ£¨μ–΄μ§‘λ‹ˆλ‹€. μ„œλ²„λ‘œ μ „μ†‘λ˜λŠ” 것은 μ—†μœΌλ―€λ‘œ ν…œν”Œλ¦Ώ, μ†ŒμŠ€ μ½”λ“œ, λ―Όκ°ν•œ λ‚΄μš©μ—λ„ μ•ˆμ „ν•©λ‹ˆλ‹€.