-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhtml-entity.html
More file actions
759 lines (674 loc) · 50.8 KB
/
Copy pathhtml-entity.html
File metadata and controls
759 lines (674 loc) · 50.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Free HTML Entity Encoder — XSS-Safe Online | FreeDevTool</title>
<meta name="description" content="Free HTML entity encoder & decoder. Convert &lt; &gt; &amp; &quot; for XSS-safe display. Named & numeric entities, Unicode support. Runs in browser.">
<meta name="keywords" content="html entity encoder, html entity decoder, html escape, html unescape, xss prevention, special characters html, named entities, numeric entities">
<meta name="robots" content="index, follow">
<meta name="author" content="Anees Ur Rehman">
<script type="application/ld+json">{"@context":"https://schema.org","@type":"WebPage","datePublished":"2026-05-02","dateModified":"2026-05-19","inLanguage":"en-US","isPartOf":{"@type":"WebSite","name":"FreeDevTool","url":"https://freedevtool.org"}}</script>
<script type="application/ld+json">{"@context":"https://schema.org","@type":"Person","name":"Anees Ur Rehman","url":"https://freedevtool.org/about","jobTitle":"Full-stack developer","worksFor":{"@type":"Organization","name":"FreeDevTool","url":"https://freedevtool.org"}}</script>
<link rel="canonical" href="https://freedevtool.org/html-entity">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="preload" href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&family=DM+Sans:wght@300;400;500;600&display=swap" as="style">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&family=DM+Sans:wght@300;400;500;600&display=swap">
<link rel="preload" href="style.css?v=20260502-cards" as="style">
<link rel="stylesheet" href="style.css?v=20260502-cards">
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="/favicon.svg">
<meta property="og:image" content="https://freedevtool.org/og-image.svg">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta property="og:image:alt" content="FreeDevTool — 50+ free, fast, privacy-first developer tools">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://freedevtool.org/og-image.svg">
<meta name="twitter:title" content="HTML Entity Encoder & Decoder — XSS-Safe | FreeDevTool">
<meta name="twitter:description" content="Encode/decode HTML entities for XSS-safe display. Named, numeric, hex entities. Runs in browser, no signup.">
<meta property="og:image" content="https://freedevtool.org/og-image.svg">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta name="twitter:image" content="https://freedevtool.org/og-image.svg">
<script async src="https://www.googletagmanager.com/gtag/js?id=G-3L0CMH3X36"></script>
<script>window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments)}gtag('js',new Date());gtag('config','G-3L0CMH3X36');</script>
<meta property="og:title" content="HTML Entity Encoder / Decoder — Free Online Tool">
<meta property="og:description" content="Encode special characters to HTML entities and decode HTML entities to text. XSS prevention.">
<meta property="og:type" content="website">
<meta property="og:url" content="https://freedevtool.org/html-entity">
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"WebApplication","name":"HTML Entity Encoder / Decoder","url":"https://freedevtool.org/html-entity","description":"Encode and decode HTML entities for special characters. Prevent XSS with proper encoding.","applicationCategory":"DeveloperApplication","operatingSystem":"Any","offers":{"@type":"Offer","price":"0","priceCurrency":"USD"}}
</script>
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"FAQPage","mainEntity":[
{"@type":"Question","name":"What are HTML entities and why are they used?","acceptedAnswer":{"@type":"Answer","text":"HTML entities are special codes that represent characters which have reserved meaning in HTML (like <, >, &, \") or aren't available on a standard keyboard (like ©, €, →). They start with & and end with ;. For example, < represents <. Without entities, browsers would interpret these characters as HTML markup."}},
{"@type":"Question","name":"How does HTML encoding prevent XSS attacks?","acceptedAnswer":{"@type":"Answer","text":"Cross-Site Scripting (XSS) attacks inject malicious HTML/JavaScript into web pages. HTML encoding converts dangerous characters like < and > into their entity equivalents (< and >), so the browser renders them as text instead of executing them as code. Always encode user-generated content before inserting it into HTML."}},
{"@type":"Question","name":"What is the difference between HTML encoding and URL encoding?","acceptedAnswer":{"@type":"Answer","text":"HTML encoding converts characters to HTML entities (& → &) for safe display in HTML documents. URL encoding converts characters to percent-encoded format (space → %20) for safe transmission in URLs. They serve different purposes and are not interchangeable."}},
{"@type":"Question","name":"What are the most common HTML entities?","acceptedAnswer":{"@type":"Answer","text":"The most common HTML entities are: & (ampersand &), < (less than <), > (greater than >), " (double quote \"), ' (single quote '), (non-breaking space), © (copyright ©), — (em dash —), and … (ellipsis …)."}},
{"@type":"Question","name":"Should I use named or numeric HTML entities?","acceptedAnswer":{"@type":"Answer","text":"Named entities like & are more readable but not all characters have named versions. Numeric entities like & (decimal) or & (hex) work for any Unicode character. For common entities, use named versions for readability. For uncommon characters, use numeric. Both are valid in all modern browsers."}},{"@type":"Question","name":"What is the HTML entity for the ampersand character?","acceptedAnswer":{"@type":"Answer","text":"& (5 characters) renders as a single ampersand. Required because a literal ampersand inside HTML markup could start an entity reference. Other essential escapes: < for less-than, > for greater-than, " for double quote, ' for apostrophe."}},{"@type":"Question","name":"How do HTML entities prevent XSS attacks?","acceptedAnswer":{"@type":"Answer","text":"Cross-site scripting (XSS) injects malicious HTML or JavaScript. Encoding user-controlled strings into HTML entities prevents them from being parsed as markup — a script payload becomes literal text instead of executing. Always escape on output, not input."}},{"@type":"Question","name":"What is the non-breaking space HTML entity?","acceptedAnswer":{"@type":"Answer","text":" is a non-breaking space — visually identical to a regular space but the browser will not break a line at this point. Used to keep words together: Mr. Smith, 100 km, Section 3.2. Excessive nbsp use breaks responsive layouts."}}
]}
</script>
<style>
.char-count { font-family:var(--mono); font-size:11px; color:var(--text3); text-align:right; margin-top:4px; }
.entity-ref { margin-top:16px; }
.entity-table {
width:100%; border-collapse:collapse; font-family:var(--mono); font-size:12px;
background:var(--bg3); border:1px solid var(--border); border-radius:var(--radius); overflow:hidden;
}
.entity-table th { background:var(--bg4); padding:8px 12px; text-align:left; font-size:10px; text-transform:uppercase; letter-spacing:.5px; color:var(--text3); }
.entity-table td { padding:6px 12px; border-top:1px solid var(--border); }
.entity-table td:first-child { font-size:16px; text-align:center; width:40px; }
.entity-table td:nth-child(2) { color:var(--accent); }
.entity-table td:nth-child(3) { color:var(--text2); }
</style>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"name": "Home",
"item": "https://freedevtool.org/"
},
{
"@type": "ListItem",
"position": 2,
"name": "All Tools",
"item": "https://freedevtool.org/all-tools"
},
{
"@type": "ListItem",
"position": 3,
"name": "HTML Entity Encoder / Decoder",
"item": "https://freedevtool.org/html-entity"
}
]
}
</script>
<script src="/ga4-events.js" defer></script>
</head>
<body>
<nav>
<a class="nav-logo" href="/" aria-label="FreeDevTool home"><svg class="logo-mark" width="22" height="22" viewBox="0 0 24 24" aria-hidden="true" fill="none"><rect x="1" y="1" width="22" height="22" rx="6" fill="currentColor" opacity=".12"/><path d="M9.5 8.5L6 12l3.5 3.5M14.5 8.5L18 12l-3.5 3.5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>FreeDevTool</a>
<div class="nav-links">
<div class="nav-dropdown" id="tools-dropdown">
<a href="all-tools" onclick="event.preventDefault();this.parentElement.classList.toggle('open')" aria-haspopup="true">Tools <svg class="chev" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg></a>
<div class="nav-dropdown-menu">
<a href="encoding-tools">
<div class="dd-icon">b64</div>
<div class="dd-info"><div class="dd-name">Encoding & Conversion</div><div class="dd-count">11 tools · Base64, YAML, px→rem</div></div>
</a>
<a href="generation-tools">
<div class="dd-icon">{ }</div>
<div class="dd-info"><div class="dd-name">Generation & Formatting</div><div class="dd-count">16 tools · JSON, SQL, gradients</div></div>
</a>
<a href="security-tools">
<div class="dd-icon">#</div>
<div class="dd-info"><div class="dd-name">Security & Hashing</div><div class="dd-count">3 tools · JWT, MD5, SHA</div></div>
</a>
<a href="text-tools">
<div class="dd-icon">.*</div>
<div class="dd-info"><div class="dd-name">Code & Text Tools</div><div class="dd-count">9 tools · Regex, diff, tokens</div></div>
</a>
<a href="devops-tools">
<div class="dd-icon">JS</div>
<div class="dd-info"><div class="dd-name">Optimization & DevOps</div><div class="dd-count">7 tools · Minifiers, cURL, git</div></div>
</a>
<a href="network-tools">
<div class="dd-icon">IP</div>
<div class="dd-info"><div class="dd-name">Network & Time</div><div class="dd-count">4 tools · IP, DNS, timestamps</div></div>
</a>
<a href="seo-tools">
<div class="dd-icon">SEO</div>
<div class="dd-info"><div class="dd-name">SEO & Meta Tools</div><div class="dd-count">3 tools · OG, meta, slug</div></div>
</a>
<div class="nav-dropdown-divider"></div>
<a class="dd-all" href="all-tools">
<div class="dd-icon">All</div>
<div class="dd-info"><div class="dd-name">Browse all 50 tools</div><div class="dd-count">Searchable catalog & categories</div></div>
</a>
</div>
</div>
<a href="/guides">Guides</a>
<a href="about">About</a>
<a href="privacy">Privacy</a>
</div>
</nav>
<div id="copy-toast">Copied!</div>
<div class="wrapper">
<a class="tool-back" href="/" aria-label="Back to home">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M15 18l-6-6 6-6"/></svg>
Back
</a>
<div class="tool-header">
<div class="tool-badge">Encoding Tool</div>
<h1>HTML Entity Encoder & Decoder Online</h1>
<p class="tool-description">
Encode special characters to HTML entities or decode entities back to readable text. Converts reserved HTML characters (<code><</code>, <code>></code>, <code>&</code>, <code>"</code>, <code>'</code>) to their entity equivalents — essential for safely displaying user-generated content and preventing <strong>Cross-Site Scripting (XSS)</strong> attacks (<a href="https://owasp.org/Top10/A03_2021-Injection/" rel="noopener" style="color:var(--accent)">OWASP Top 10</a>). Supports named entities (<code>&amp;</code>), decimal numeric (<code>&#38;</code>), hex numeric (<code>&#x26;</code>), and full Unicode escape. Runs in your browser; even sensitive payloads stay local.
</p>
<div class="last-updated">Last updated: May 2026 · Written by <a href="/about">Anees Ur Rehman</a>, full-stack developer</div>
</div>
<div class="tool-card">
<div class="tool-card-header">
<div class="dot dot-red"></div><div class="dot dot-yellow"></div><div class="dot dot-green"></div>
<span class="tool-card-title">html-entity.tool</span>
</div>
<div class="tool-body">
<div class="tabs">
<button class="tab active" onclick="setMode('encode',this)">Encode</button>
<button class="tab" onclick="setMode('decode',this)">Decode</button>
</div>
<div id="mode-encode">
<label>Text with special characters</label>
<textarea id="encode-input" placeholder='<script>alert("XSS")</script> & "quotes" ©2025' oninput="doEncode()" rows="4"></textarea>
<div class="char-count" id="encode-count">0 characters</div>
<div style="margin-top:8px">
<label style="display:flex;align-items:center;gap:6px;text-transform:none;letter-spacing:normal;font-size:12px;cursor:pointer;margin:0">
<input type="checkbox" id="encode-all" onchange="doEncode()"> Encode all characters (not just reserved)
</label>
</div>
<div class="divider"></div>
<div class="output-label">
<label style="margin:0">HTML Entities Output</label>
<button class="btn btn-ghost" onclick="copyOutput('encode-output')">Copy</button>
</div>
<div class="output-block" id="encode-output" style="color:var(--text2);font-style:italic">Output will appear here...</div>
</div>
<div id="mode-decode" style="display:none">
<label>HTML entities to decode</label>
<textarea id="decode-input" placeholder="<script>alert("XSS")</script> & "quotes" ©2025" oninput="doDecode()" rows="4"></textarea>
<div class="char-count" id="decode-count">0 characters</div>
<div class="divider"></div>
<div class="output-label">
<label style="margin:0">Decoded Text</label>
<button class="btn btn-ghost" onclick="copyOutput('decode-output')">Copy</button>
</div>
<div class="output-block" id="decode-output" style="color:var(--text2);font-style:italic">Output will appear here...</div>
</div>
<div class="divider"></div>
<div class="entity-ref">
<label>Common HTML Entities Reference</label>
<table class="entity-table">
<tr><th>Char</th><th>Named</th><th>Numeric</th><th>Description</th></tr>
<tr><td>&</td><td>&amp;</td><td>&#38;</td><td>Ampersand</td></tr>
<tr><td><</td><td>&lt;</td><td>&#60;</td><td>Less than</td></tr>
<tr><td>></td><td>&gt;</td><td>&#62;</td><td>Greater than</td></tr>
<tr><td>"</td><td>&quot;</td><td>&#34;</td><td>Double quote</td></tr>
<tr><td>'</td><td>&#39;</td><td>&#39;</td><td>Single quote</td></tr>
<tr><td> </td><td>&nbsp;</td><td>&#160;</td><td>Non-breaking space</td></tr>
<tr><td>©</td><td>&copy;</td><td>&#169;</td><td>Copyright</td></tr>
<tr><td>—</td><td>&mdash;</td><td>&#8212;</td><td>Em dash</td></tr>
<tr><td>→</td><td>&rarr;</td><td>&#8594;</td><td>Right arrow</td></tr>
<tr><td>…</td><td>&hellip;</td><td>&#8230;</td><td>Ellipsis</td></tr>
</table>
</div>
</div>
</div>
<!-- =============================================================
LONG-FORM ARTICLE — comprehensive guide for E-E-A-T + ranking.
============================================================= -->
<article>
<p class="aeo-lead" style="font-size:16px;line-height:1.7;color:var(--text);max-width:760px;margin:24px auto 18px;padding:0 4px">
<strong>HTML entities</strong> are escape sequences (<code>&amp;</code>, <code>&lt;</code>, <code>&gt;</code>, <code>&#169;</code>) that represent characters which would otherwise be parsed as HTML markup or are difficult to type. Named entities are more readable (<code>&copy;</code>); numeric entities are more compatible across older renderers (<code>&#169;</code>). This <strong>free HTML entity encoder and decoder</strong> outputs both formats and is essential for XSS-safe content rendering.
</p>
<section id="examples" style="max-width:760px;margin:24px auto 32px">
<h2 style="font-size:18px;margin-bottom:14px">Examples</h2>
<div style="background:var(--bg3);border:1px solid var(--border);border-radius:var(--radius);padding:16px;margin-bottom:12px">
<strong style="display:block;color:var(--accent);font-family:var(--mono);font-size:11px;text-transform:uppercase;letter-spacing:1px;margin-bottom:6px">Common entity reference§§< → <§§> → >§§" → "§§& → &§§' → '§§These 5 entities are the minimum needed to escape any user-controlled string for safe HTML rendering.</strong>
</div>
<div style="background:var(--bg3);border:1px solid var(--border);border-radius:var(--radius);padding:16px;margin-bottom:12px">
<strong style="display:block;color:var(--accent);font-family:var(--mono);font-size:11px;text-transform:uppercase;letter-spacing:1px;margin-bottom:6px">Named vs numeric§§© → © (named, readable) OR © (numeric, universal compatibility)§§Named entities are easier for humans; numeric entities are guaranteed in every browser including legacy.</strong>
</div>
<div style="background:var(--bg3);border:1px solid var(--border);border-radius:var(--radius);padding:16px;margin-bottom:12px">
<strong style="display:block;color:var(--accent);font-family:var(--mono);font-size:11px;text-transform:uppercase;letter-spacing:1px;margin-bottom:6px">Non-breaking space§§ prevents line breaks at the space, useful for "Mr. Smith" or "100 km" where the words must stay together.</strong>
</div>
</section>
<aside class="founder-note" style="max-width:760px;margin:24px auto 32px;padding:20px 24px;background:rgba(0,208,132,0.05);border-left:3px solid var(--accent);border-radius:6px;font-size:14px;line-height:1.7;color:var(--text2)"><div style="font-family:var(--mono);font-size:11px;color:var(--accent);letter-spacing:1.5px;text-transform:uppercase;margin-bottom:10px;font-weight:600">💡 Why I built this</div><p style="margin:0 0 12px">I built this after pasting a Stack Overflow code snippet into a customer email template and watching the email server eat every angle bracket. Stack Overflow used named entities but the legacy mail client only supported numeric entities. This tool gives you both formats — named (readable) and numeric (compatible) — so you can pick whichever your renderer actually accepts.</p><p style="margin:0;font-size:13px;color:var(--text3)">— <a href="/about" style="color:var(--accent);text-decoration:none">Anees Ur Rehman</a>, full-stack developer</p></aside>
<section class="article-section">
<h2>What are HTML entities and why do they matter?</h2>
<p>An <strong>HTML entity</strong> is a special sequence of characters that represents a reserved or non-printable character in HTML markup. They start with an ampersand (<code>&</code>) and end with a semicolon (<code>;</code>). The entity <code>&lt;</code> renders as <code><</code>, <code>&amp;</code> renders as <code>&</code>, <code>&copy;</code> renders as <code>©</code>. Defined originally in <a href="https://www.w3.org/TR/html401/sgml/entities.html" rel="noopener">HTML 4.01</a> and extended in HTML5 to over 2,000 named entities, they exist for two reasons: <strong>escaping reserved characters</strong> (so the browser doesn't think your text is markup) and <strong>typing characters that aren't on your keyboard</strong> (em dashes, math symbols, currency).</p>
<p>The five mandatory escapes — the ones that XSS-prevention guides drill into every web developer:</p>
<table class="ref-table">
<thead><tr><th>Char</th><th>Named entity</th><th>Numeric (decimal)</th><th>Numeric (hex)</th><th>Why escape?</th></tr></thead>
<tbody>
<tr><td><code><</code></td><td><code>&lt;</code></td><td><code>&#60;</code></td><td><code>&#x3C;</code></td><td>Starts a tag — the #1 XSS vector</td></tr>
<tr><td><code>></code></td><td><code>&gt;</code></td><td><code>&#62;</code></td><td><code>&#x3E;</code></td><td>Ends a tag</td></tr>
<tr><td><code>&</code></td><td><code>&amp;</code></td><td><code>&#38;</code></td><td><code>&#x26;</code></td><td>Starts an entity — escape to literal</td></tr>
<tr><td><code>"</code></td><td><code>&quot;</code></td><td><code>&#34;</code></td><td><code>&#x22;</code></td><td>Closes attribute values</td></tr>
<tr><td><code>'</code> (apostrophe)</td><td><code>&apos;</code> (HTML5)</td><td><code>&#39;</code></td><td><code>&#x27;</code></td><td>Closes single-quoted attributes</td></tr>
</tbody>
</table>
<p>If your application takes user input and renders it inside HTML without escaping these five characters, you have an <strong>XSS vulnerability</strong>. Every modern web framework escapes by default; raw string concatenation or "trust-us" templating bypasses that protection. This is why <code>innerHTML</code> with user data is dangerous and <code>textContent</code> is safe.</p>
</section>
<section class="article-section">
<h2>Named vs numeric vs hex — three ways to encode the same character</h2>
<table class="ref-table">
<thead><tr><th>Form</th><th>Example</th><th>Pros</th><th>Cons</th></tr></thead>
<tbody>
<tr><td><strong>Named entity</strong></td><td><code>&copy;</code></td><td>Readable, memorable</td><td>~2,000 names; not all parsers support all of them</td></tr>
<tr><td><strong>Decimal numeric</strong></td><td><code>&#169;</code></td><td>Universal — every char has a decimal code point</td><td>Less readable than named</td></tr>
<tr><td><strong>Hex numeric</strong></td><td><code>&#xA9;</code></td><td>Matches Unicode references (U+00A9)</td><td>Slightly less common; same support as decimal</td></tr>
</tbody>
</table>
<p>For the five mandatory escapes, named entities are universally supported and most readable. For uncommon symbols (em dash, em space, math operators, arrows), numeric entities are safer because every parser recognizes them. <strong>Always include the trailing semicolon</strong> — most browsers tolerate missing semicolons in HTML5, but XML and strict parsers reject the entity entirely.</p>
<h3>HTML5's named-entity gotchas</h3>
<ul>
<li><code>&apos;</code> only became official in HTML5. It works in modern browsers but breaks in XHTML 1.0 — use <code>&#39;</code> if XHTML compatibility matters.</li>
<li>Some "obvious" names don't exist. There's no <code>&asterisk;</code> or <code>&dollar;</code> — those are plain ASCII. Don't over-escape.</li>
<li>Case matters. <code>&Auml;</code> = Ä, <code>&auml;</code> = ä — different characters.</li>
</ul>
</section>
<section class="article-section">
<h2>Useful named entities by category</h2>
<h3>Currency & math</h3>
<table class="ref-table">
<thead><tr><th>Symbol</th><th>Named</th><th>Numeric</th></tr></thead>
<tbody>
<tr><td>©</td><td><code>&copy;</code></td><td><code>&#169;</code></td></tr>
<tr><td>®</td><td><code>&reg;</code></td><td><code>&#174;</code></td></tr>
<tr><td>™</td><td><code>&trade;</code></td><td><code>&#8482;</code></td></tr>
<tr><td>€</td><td><code>&euro;</code></td><td><code>&#8364;</code></td></tr>
<tr><td>£</td><td><code>&pound;</code></td><td><code>&#163;</code></td></tr>
<tr><td>¥</td><td><code>&yen;</code></td><td><code>&#165;</code></td></tr>
<tr><td>×</td><td><code>&times;</code></td><td><code>&#215;</code></td></tr>
<tr><td>÷</td><td><code>&divide;</code></td><td><code>&#247;</code></td></tr>
<tr><td>±</td><td><code>&plusmn;</code></td><td><code>&#177;</code></td></tr>
<tr><td>°</td><td><code>&deg;</code></td><td><code>&#176;</code></td></tr>
</tbody>
</table>
<h3>Punctuation & whitespace</h3>
<table class="ref-table">
<thead><tr><th>Symbol</th><th>Named</th><th>Numeric</th></tr></thead>
<tbody>
<tr><td>(non-breaking space)</td><td><code>&nbsp;</code></td><td><code>&#160;</code></td></tr>
<tr><td>—</td><td><code>&mdash;</code></td><td><code>&#8212;</code></td></tr>
<tr><td>–</td><td><code>&ndash;</code></td><td><code>&#8211;</code></td></tr>
<tr><td>…</td><td><code>&hellip;</code></td><td><code>&#8230;</code></td></tr>
<tr><td>"</td><td><code>&ldquo;</code></td><td><code>&#8220;</code></td></tr>
<tr><td>"</td><td><code>&rdquo;</code></td><td><code>&#8221;</code></td></tr>
<tr><td>'</td><td><code>&lsquo;</code></td><td><code>&#8216;</code></td></tr>
<tr><td>'</td><td><code>&rsquo;</code></td><td><code>&#8217;</code></td></tr>
<tr><td>«</td><td><code>&laquo;</code></td><td><code>&#171;</code></td></tr>
<tr><td>»</td><td><code>&raquo;</code></td><td><code>&#187;</code></td></tr>
<tr><td>·</td><td><code>&middot;</code></td><td><code>&#183;</code></td></tr>
<tr><td>•</td><td><code>&bull;</code></td><td><code>&#8226;</code></td></tr>
</tbody>
</table>
<h3>Arrows</h3>
<table class="ref-table">
<thead><tr><th>Symbol</th><th>Named</th><th>Numeric</th></tr></thead>
<tbody>
<tr><td>←</td><td><code>&larr;</code></td><td><code>&#8592;</code></td></tr>
<tr><td>→</td><td><code>&rarr;</code></td><td><code>&#8594;</code></td></tr>
<tr><td>↑</td><td><code>&uarr;</code></td><td><code>&#8593;</code></td></tr>
<tr><td>↓</td><td><code>&darr;</code></td><td><code>&#8595;</code></td></tr>
<tr><td>⇐</td><td><code>&lArr;</code></td><td><code>&#8656;</code></td></tr>
<tr><td>⇒</td><td><code>&rArr;</code></td><td><code>&#8658;</code></td></tr>
</tbody>
</table>
</section>
<section class="article-section">
<h2>HTML entity encoding for XSS prevention — the critical rules</h2>
<p><strong>XSS (Cross-Site Scripting)</strong> happens when user-supplied content is rendered as HTML/JavaScript instead of as text. The fix: encode user input before placing it in an HTML context. But "an HTML context" is plural — different contexts need different encoding.</p>
<table class="ref-table">
<thead><tr><th>Context</th><th>Example</th><th>Required encoding</th></tr></thead>
<tbody>
<tr><td>HTML body / text node</td><td><code><p>USER</p></code></td><td>Escape <code>< > &</code></td></tr>
<tr><td>HTML attribute (quoted)</td><td><code><a title="USER"></code></td><td>Escape <code>< > & "</code></td></tr>
<tr><td>HTML attribute (unquoted)</td><td><code><a title=USER></code></td><td>Encode every non-alphanumeric (or quote the attribute)</td></tr>
<tr><td>JavaScript context</td><td><code><script>var x = "USER";</script></code></td><td>JavaScript escape (<code>\x3C</code>), NOT HTML escape</td></tr>
<tr><td>CSS context</td><td><code><style>.a { content: "USER" }</style></code></td><td>CSS escape (<code>\3C</code>), NOT HTML escape</td></tr>
<tr><td>URL parameter</td><td><code><a href="?q=USER"></code></td><td>URL encode (<code>%3C</code>), NOT HTML escape</td></tr>
</tbody>
</table>
<p><strong>The classic mistake:</strong> HTML-escaping content that ends up inside JavaScript. <code>&lt;</code> becomes a literal in JS — the <code><</code> is never recovered. Use the right escape for the destination context, not the source.</p>
<div class="article-aside">
<strong>Defense in depth:</strong> use a Content Security Policy (CSP) header that bans inline scripts (<code>script-src 'self'</code>). Even if escaping fails, CSP blocks the attack.
</div>
</section>
<section class="article-section">
<h2>HTML escaping in 8 programming languages</h2>
<h3>JavaScript</h3>
<div class="lang-block">
<div class="lang-block-header">javascript</div>
<pre><code>// Modern: use textContent (no encoding bugs possible)
el.textContent = userInput; // Safe ✓
// If you MUST build HTML strings, escape manually
function escapeHtml(s) {
return s.replace(/[&<>"']/g, c => ({
'&': '&amp;', '<': '&lt;', '>': '&gt;',
'"': '&quot;', "'": '&#39;'
}[c]));
}
// To DECODE entities (use a textarea — the browser does it)
function decodeHtml(s) {
const ta = document.createElement('textarea');
ta.innerHTML = s;
return ta.value;
}
</code></pre>
</div>
<h3>Python</h3>
<div class="lang-block">
<div class="lang-block-header">python</div>
<pre><code>import html
html.escape("<script>alert(1)</script>")
# '&lt;script&gt;alert(1)&lt;/script&gt;'
html.escape("It's & \"quoted\"", quote=True)
# 'It&#x27;s &amp; &quot;quoted&quot;'
# Decode
html.unescape("&lt;p&gt;Hello&lt;/p&gt;") # '<p>Hello</p>'
</code></pre>
</div>
<h3>PHP</h3>
<div class="lang-block">
<div class="lang-block-header">php</div>
<pre><code>// Mandatory: htmlspecialchars (escapes 5 reserved chars)
echo htmlspecialchars($input, ENT_QUOTES | ENT_HTML5, 'UTF-8');
// htmlentities — encodes ALL applicable entities (rarely what you want)
echo htmlentities($input, ENT_QUOTES | ENT_HTML5, 'UTF-8');
// Decode
echo html_entity_decode($input, ENT_QUOTES | ENT_HTML5, 'UTF-8');
</code></pre>
</div>
<h3>Java</h3>
<div class="lang-block">
<div class="lang-block-header">java</div>
<pre><code>// Apache Commons Text
import org.apache.commons.text.StringEscapeUtils;
String safe = StringEscapeUtils.escapeHtml4(userInput);
String back = StringEscapeUtils.unescapeHtml4(safe);
// OWASP Java Encoder (recommended for XSS prevention)
import org.owasp.encoder.Encode;
String safe = Encode.forHtml(userInput);
String safeAttr = Encode.forHtmlAttribute(userInput);
String safeJs = Encode.forJavaScript(userInput); // different escape!
</code></pre>
</div>
<h3>Go</h3>
<div class="lang-block">
<div class="lang-block-header">go</div>
<pre><code>import "html"
escaped := html.EscapeString("<script>")
// "&lt;script&gt;"
unescaped := html.UnescapeString("&lt;p&gt;hi&lt;/p&gt;")
// "<p>hi</p>"
// In Go templates, html/template auto-escapes by default — use it:
import "html/template"
t := template.Must(template.New("x").Parse(`<p>{{.}}</p>`))
t.Execute(os.Stdout, "<script>") // automatically escaped
</code></pre>
</div>
<h3>Ruby</h3>
<div class="lang-block">
<div class="lang-block-header">ruby</div>
<pre><code>require 'cgi'
CGI.escapeHTML("<script>alert(1)</script>")
# "&lt;script&gt;alert(1)&lt;/script&gt;"
CGI.unescapeHTML("&lt;p&gt;hi&lt;/p&gt;")
# "<p>hi</p>"
# In Rails ERB, the <%= %> syntax auto-escapes
<%= user.name %> # auto-escaped, safe
<%= raw user.name %> # NOT escaped — only when you've already trusted the input
</code></pre>
</div>
<h3>Rust</h3>
<div class="lang-block">
<div class="lang-block-header">rust</div>
<pre><code>use html_escape::{encode_text, decode_html_entities};
let safe = encode_text("<script>");
// "&lt;script&gt;"
let back = decode_html_entities("&lt;p&gt;");
// "<p>"
// Or use Askama / Tera templates — they auto-escape
</code></pre>
</div>
<h3>Bash (recode / sed / xmlstarlet)</h3>
<div class="lang-block">
<div class="lang-block-header">bash</div>
<pre><code># GNU recode
echo '<p>Hello & world</p>' | recode html..ascii
# "&lt;p&gt;Hello &amp; world&lt;/p&gt;"
# Plain sed (5 mandatory chars)
sed -e 's/&/\&amp;/g' -e 's/</\&lt;/g' -e 's/>/\&gt;/g' \
-e 's/"/\&quot;/g' -e "s/'/\&#39;/g"
# Decode with xmlstarlet
echo '&lt;p&gt;hi&lt;/p&gt;' | xmlstarlet unesc
</code></pre>
</div>
</section>
<section class="article-section">
<h2>HTML entity best practices</h2>
<ul>
<li><strong>Always use auto-escaping templating engines.</strong> Jinja2, ERB, Thymeleaf, html/template (Go), React's JSX — all escape by default. Manual escaping is bug-prone.</li>
<li><strong>Use <code>textContent</code> in JavaScript</strong>, not <code>innerHTML</code>, when inserting user data. Eliminates the encoding question entirely.</li>
<li><strong>Never trust input from anywhere.</strong> Database content, third-party APIs, your own admin panel — all can be sources of XSS payloads.</li>
<li><strong>Encode at the boundary, not the storage.</strong> Store raw user input; encode only when rendering. Lets you change templates and re-render correctly.</li>
<li><strong>Pick the right encoder for the context.</strong> HTML escape, JS escape, URL encode, CSS escape — they're all different. OWASP's library handles them all.</li>
<li><strong>Layer defenses with CSP.</strong> Even if XSS slips through, a tight Content Security Policy blocks inline-script execution.</li>
<li><strong>Sanitize, don't escape, when allowing some HTML.</strong> If users paste rich content, use <a href="https://github.com/cure53/DOMPurify" rel="noopener">DOMPurify</a> (JS) or Bleach (Python) to strip dangerous tags. Don't try to write a regex sanitizer.</li>
<li><strong>Don't HTML-escape data going into JSON.</strong> JSON has different rules — use <code>JSON.stringify</code> or your language's JSON library.</li>
</ul>
</section>
</article>
<!-- How to use + mistakes -->
<section class="use-cases">
<h2>How to use the HTML entity encoder</h2>
<p>Convert special characters to HTML entities (<code>&lt;</code>, <code>&amp;</code>, <code>&quot;</code>) so they render as text inside HTML instead of being parsed as markup. Essential for displaying user-submitted content safely (XSS prevention), embedding code samples in blog posts, and quoting HTML inside JavaScript strings.</p>
<ul class="use-case-list">
<li><strong>1.</strong> Pick "Encode" (text → entities) or "Decode" (entities → text). Auto-detect chooses based on whether the input has <code>&</code> sequences.</li>
<li><strong>2.</strong> Paste your content. The encoder handles all five mandatory chars (<code>< > & " '</code>) plus optional Unicode entities for non-ASCII.</li>
<li><strong>3.</strong> Toggle "Encode all non-ASCII" to convert characters like <code>é</code> to <code>&#233;</code> — useful for older systems that mangle UTF-8.</li>
<li><strong>4.</strong> Pick named entities (<code>&copy;</code>) or numeric (<code>&#169;</code>). Named are more readable; numeric work even if your DOCTYPE doesn't declare HTML5.</li>
<li><strong>5.</strong> Copy the output. Safe to paste into any HTML attribute, text node, or JavaScript string literal.</li>
</ul>
<h3>Common mistakes to avoid</h3>
<ul class="mistakes-list">
<li><strong>Forgetting to encode user input.</strong> Inserting raw user text into HTML is the #1 source of XSS vulnerabilities. Always encode on output, even if you sanitized on input.</li>
<li><strong>Encoding only <code><</code> and <code>></code>.</strong> You also need <code>&</code>, <code>"</code>, and <code>'</code> for full XSS safety, especially inside attribute values.</li>
<li><strong>Confusing HTML entities with URL encoding.</strong> <code>&amp;</code> is HTML; <code>%26</code> is URL. Mixing them inside <code>href</code> attributes causes broken links.</li>
<li><strong>Double-encoding.</strong> If the framework already encoded, encoding again displays literal <code>&amp;lt;</code> on the page. Encode at exactly one boundary — typically the template engine.</li>
<li><strong>Trusting that <code>innerHTML</code> = entity-encoded content.</strong> When you read <code>el.innerHTML</code>, the browser may normalize entities. Use <code>textContent</code> when you want raw text without HTML parsing.</li>
<li><strong>Using HTML entities inside <code><script></code> or <code><style></code>.</strong> Those blocks are parsed as raw text, not HTML. Use JS string escapes (<code>\u0026</code>) and CSS escapes inside them.</li>
</ul>
</section>
<section class="faq-section">
<h2>Frequently Asked Questions</h2>
<div class="faq-item open">
<div class="faq-q" onclick="toggleFaq(this)">What are HTML entities and why are they used?<svg class="chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg></div>
<div class="faq-a">HTML entities are special codes that represent characters which have <strong>reserved meaning in HTML</strong> (like <code><</code>, <code>></code>, <code>&</code>) or characters not available on a standard keyboard (like <code>©</code>, <code>€</code>, <code>→</code>). They follow the format <code>&name;</code> or <code>&#number;</code>. Without entities, browsers would misinterpret these characters as HTML tags or markup, breaking the page layout or creating security vulnerabilities.</div>
</div>
<div class="faq-item">
<div class="faq-q" onclick="toggleFaq(this)">How does HTML encoding prevent XSS attacks?<svg class="chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg></div>
<div class="faq-a"><strong>Cross-Site Scripting (XSS)</strong> attacks inject malicious HTML or JavaScript into web pages. HTML encoding converts dangerous characters like <code><</code> and <code>></code> into their entity equivalents (<code>&lt;</code> and <code>&gt;</code>), so the browser renders them as visible text instead of executing them as code. This is a critical defense — always encode user-generated content before inserting it into HTML. The OWASP Top 10 lists XSS as one of the most common web vulnerabilities.</div>
</div>
<div class="faq-item">
<div class="faq-q" onclick="toggleFaq(this)">What is the difference between HTML encoding and URL encoding?<svg class="chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg></div>
<div class="faq-a"><strong>HTML encoding</strong> converts characters to HTML entities (<code>&</code> → <code>&amp;</code>) for safe display inside HTML documents. <strong>URL encoding</strong> converts characters to percent-encoded format (<code>space</code> → <code>%20</code>) for safe use in URLs. They serve different purposes: HTML encoding prevents markup injection in web pages, URL encoding ensures special characters are transmitted correctly in URLs. They are not interchangeable.</div>
</div>
<div class="faq-item">
<div class="faq-q" onclick="toggleFaq(this)">Should I use named or numeric HTML entities?<svg class="chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg></div>
<div class="faq-a">Named entities like <code>&amp;</code> are more human-readable but not every character has a named version. Numeric entities — decimal (<code>&#38;</code>) or hexadecimal (<code>&#x26;</code>) — work for <strong>any</strong> Unicode character. For common entities (<code>&lt;</code>, <code>&gt;</code>, <code>&amp;</code>), use named versions for readability. For uncommon or Unicode characters, use numeric entities. Both are valid in all modern browsers and HTML5.</div>
</div>
<div class="faq-item">
<div class="faq-q" onclick="toggleFaq(this)">Which character encoding should I use — UTF-8 or ASCII?<svg class="chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg></div>
<div class="faq-a"><strong>UTF-8</strong> — always. The W3C and WHATWG HTML5 spec both recommend UTF-8 as the default character encoding. UTF-8 supports all Unicode characters (emoji, CJK, Arabic, etc.) while remaining backward-compatible with ASCII. Set <code><meta charset="UTF-8"></code> in your HTML <code><head></code>. Over 98% of websites use UTF-8 as of 2026.</div>
</div>
</section>
<section class="related-section">
<h2>Related Tools</h2>
<div class="related-grid">
<a class="related-card" href="url-encoder"><div class="related-icon">%</div><div class="related-card-info"><div class="related-card-name">URL Encoder / Decoder</div><div class="related-card-desc">Percent-encode and decode URLs</div></div></a>
<a class="related-card" href="base64-encoder"><div class="related-icon">b64</div><div class="related-card-info"><div class="related-card-name">Base64 Encoder</div><div class="related-card-desc">Encode and decode Base64 strings</div></div></a>
<a class="related-card" href="css-minifier"><div class="related-icon">CSS</div><div class="related-card-info"><div class="related-card-name">CSS Minifier</div><div class="related-card-desc">Minify and beautify CSS</div></div></a>
</div>
</section>
<section class="all-tools-section" aria-label="Browse all FreeDevTool developer tools">
<h2>Browse all 50 free developer tools</h2>
<p class="atc-sub">All tools run in your browser, no signup required, nothing sent to a server.</p>
<div class="all-tools-grid">
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">b64</div>
<div class="atc-cat-title"><h3>Encoding & Conversion</h3><span class="atc-cat-count">11 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/base64-encoder">Base64 Encoder / Decoder</a></li>
<li><a href="/base64-image">Image to Base64</a></li>
<li><a href="/byte-converter">Byte Converter (KB / MB / GB)</a></li>
<li><a href="/case-converter">Case Converter</a></li>
<li><a href="/hex-to-rgb">Hex to RGB / HSL</a></li>
<li><a href="/html-entity">HTML Entity Encoder</a></li>
<li><a href="/json-to-csv">JSON to CSV Converter</a></li>
<li><a href="/px-to-rem">PX to REM Converter</a></li>
<li><a href="/string-escape">String Escape / Unescape</a></li>
<li><a href="/url-encoder">URL Encoder / Decoder</a></li>
<li><a href="/yaml-to-json">YAML to JSON Converter</a></li>
</ul>
</div>
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">{ }</div>
<div class="atc-cat-title"><h3>Formatting & Generators</h3><span class="atc-cat-count">13 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/color-name">Color Name from Hex</a></li>
<li><a href="/color-picker">Color Palette Picker</a></li>
<li><a href="/css-box-shadow">CSS Box Shadow</a></li>
<li><a href="/css-gradient">CSS Gradient Generator</a></li>
<li><a href="/json-formatter">JSON Formatter / Validator</a></li>
<li><a href="/lorem-ipsum">Lorem Ipsum Generator</a></li>
<li><a href="/markdown-preview">Markdown Preview</a></li>
<li><a href="/password-generator">Password Generator</a></li>
<li><a href="/qr-generator">QR Code Generator</a></li>
<li><a href="/sql-formatter">SQL Formatter</a></li>
<li><a href="/uuid-generator">UUID Generator</a></li>
<li><a href="/word-to-markdown">Word to Markdown</a></li>
<li><a href="/xml-formatter">XML Formatter</a></li>
</ul>
</div>
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">JS</div>
<div class="atc-cat-title"><h3>Minifiers & DevOps</h3><span class="atc-cat-count">6 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/chmod-calculator">chmod Calculator</a></li>
<li><a href="/cron-parser">Cron Expression Parser</a></li>
<li><a href="/css-minifier">CSS Minifier</a></li>
<li><a href="/html-minifier">HTML Minifier</a></li>
<li><a href="/js-minifier">JavaScript Minifier</a></li>
<li><a href="/http-status">HTTP Status Codes</a></li>
</ul>
</div>
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">#</div>
<div class="atc-cat-title"><h3>Security & Hashing</h3><span class="atc-cat-count">3 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/hash-generator">Hash Generator (MD5, SHA)</a></li>
<li><a href="/jwt-decoder">JWT Decoder</a></li>
<li><a href="/jwt-generator">JWT Generator</a></li>
</ul>
</div>
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">.*</div>
<div class="atc-cat-title"><h3>Code & Text</h3><span class="atc-cat-count">8 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/ai-token-counter">AI Token Counter</a></li>
<li><a href="/char-counter">Character & Word Counter</a></li>
<li><a href="/git-cheatsheet">Git Commands Cheatsheet</a></li>
<li><a href="/number-base">Number Base Converter</a></li>
<li><a href="/regex-explainer">Regex Explainer</a></li>
<li><a href="/regex-tester">Regex Tester</a></li>
<li><a href="/text-diff">Text Diff Checker</a></li>
<li><a href="/wcag-contrast">WCAG Contrast Checker</a></li>
</ul>
</div>
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">IP</div>
<div class="atc-cat-title"><h3>Network & APIs</h3><span class="atc-cat-count">3 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/dns-lookup">DNS Lookup</a></li>
<li><a href="/http-request-builder">HTTP Request Builder</a></li>
<li><a href="/ip-lookup">IP Address Lookup</a></li>
</ul>
</div>
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">⏱</div>
<div class="atc-cat-title"><h3>Time & Dates</h3><span class="atc-cat-count">3 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/relative-time">Relative Time Calculator</a></li>
<li><a href="/timestamp-diff">Timestamp Diff</a></li>
<li><a href="/unix-timestamp-converter">Unix Timestamp Converter</a></li>
</ul>
</div>
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">SEO</div>
<div class="atc-cat-title"><h3>SEO & Meta</h3><span class="atc-cat-count">3 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/meta-tag-generator">Meta Tag Generator</a></li>
<li><a href="/og-preview">Open Graph Preview</a></li>
<li><a href="/slug-generator">URL Slug Generator</a></li>
</ul>
</div>
</div>
</section>
</div>
<footer>
<div>© 2026 FreeDevTool — HTML Entity Encoder / Decoder</div>
<div class="footer-links"><a href="/all-tools">All Tools</a><a href="/about">About</a><a href="/privacy">Privacy Policy</a><a href="/terms">Terms of Use</a></div>
</footer>
<script>
function setMode(mode, btn) {
document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
btn.classList.add('active');
document.getElementById('mode-encode').style.display = mode === 'encode' ? '' : 'none';
document.getElementById('mode-decode').style.display = mode === 'decode' ? '' : 'none';
}
function doEncode() {
const input = document.getElementById('encode-input').value;
document.getElementById('encode-count').textContent = input.length + ' characters';
const out = document.getElementById('encode-output');
if (!input) { out.textContent = 'Output will appear here...'; out.style.fontStyle='italic'; out.style.color='var(--text2)'; return; }
const encodeAll = document.getElementById('encode-all').checked;
let result;
if (encodeAll) {
result = [...input].map(c => '&#' + c.codePointAt(0) + ';').join('');
} else {
result = input.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/'/g,''');
}
out.textContent = result; out.style.fontStyle='normal'; out.style.color='var(--text)';
}
function doDecode() {
const input = document.getElementById('decode-input').value;
document.getElementById('decode-count').textContent = input.length + ' characters';
const out = document.getElementById('decode-output');
if (!input) { out.textContent = 'Output will appear here...'; out.style.fontStyle='italic'; out.style.color='var(--text2)'; return; }
const el = document.createElement('textarea');
el.innerHTML = input;
out.textContent = el.value;
out.style.fontStyle='normal'; out.style.color='var(--text)';
}
function copyOutput(id) {
const t = document.getElementById(id).textContent;
if (t) { navigator.clipboard.writeText(t); showToast(); }
}
function showToast() { const t=document.getElementById('copy-toast');t.classList.add('show');setTimeout(()=>t.classList.remove('show'),1800); }
function toggleFaq(el) { el.parentElement.classList.toggle('open'); }
</script>
<script>document.addEventListener('click',e=>{const dd=document.getElementById('tools-dropdown');if(dd&&!dd.contains(e.target))dd.classList.remove('open')});</script>
</body>
</html>