Base58 Encoding Explained: Bitcoin Addresses, IPFS CIDs, and Compact IDs
Learn when Base58 beats Base64 — alphabet rules, leading-zero handling, checksum variants, and how to encode or decode safely in the browser.
Named and numeric HTML entities, when to encode, XSS pitfalls, and how entity lookup pairs with MIME awareness when pasting content into HTML and email.
By codefunc
HTML is text with special characters. Angle brackets open tags, ampersands start character references, and quotes delimit attributes. When user content or CMS copy hits those characters unescaped, browsers parse markup you never intended — broken layouts at best, XSS at worst. HTML entities (character references) are how you keep text as text. Knowing which entity to reach for — and when encoding is the wrong layer — is core frontend hygiene.
Bottom line: Escape &, <, >, ", and ' in the right contexts; prefer clear named or numeric references when you need literal symbols; never "encode" as a substitute for proper HTML sanitization of rich text. Look up symbols with HTML Entity Lookup, transform bulk text with HTML Entities, and confirm file/content types with MIME Type Lookup when the same payload moves across HTML, email, and APIs.
Frontend developers who render user-generated content, build email templates, or debug "why does & show up twice?" If you paste Word docs into CMS fields or assemble HTML strings in JS, this guide maps the rules that prevent double-encoding and injection.
A character reference is a textual stand-in for a Unicode character in HTML:
| Form | Example | Notes |
|---|---|---|
| Named | © & |
Easy to read; finite set |
| Decimal numeric |   |
Works for any code point |
| Hex numeric |   |
Same as decimal, hex form |
The browser decodes references when parsing HTML into the DOM. The DOM's text nodes hold real Unicode — not the entity source — unless you inspect innerHTML and see re-serialized escapes.
For text content inside elements:
| Char | Entity | Why |
|---|---|---|
& |
& |
Starts every reference; must be escaped when literal |
< |
< |
Starts tags |
> |
> |
Often escaped for symmetry / legacy |
" |
" |
Critical inside double-quoted attributes |
' |
' or ' |
Critical inside single-quoted attributes |
In modern HTML, ' is fine; older XHTML habits vary. In JS, prefer APIs that set textContent or use framework escaping so you do not hand-roll attribute rules.
< and & at minimum<script> / <style>: HTML entity rules are the wrong tool — these are special contexts with their own parsing; do not assemble JS with HTML escapes alonehref: use URL encoding, not HTML entities, for query bytes; still escape & in the HTML source as & between query params| Entity | Character | Use |
|---|---|---|
|
non-breaking space | Prevent awkward wraps (sparingly) |
— / – |
— / – | Typography in CMS content |
“ ” |
“ ” | Curly quotes in prose |
© ® ™ |
© ® ™ | Legal lines |
× · |
× · | UI separators |
→ |
→ | Lightweight indicators |
When you forget a name, search by symbol or code point in HTML Entity Lookup instead of guessing from memory.
Encode when you take plain text and need safe HTML source:
Tom & Jerry → Tom & Jerry
Decode when you have HTML source or CMS output and need the readable string:
Tom & Jerry → Tom & Jerry
Double-encoding is the classic CMS bug: &amp; appears in the UI. It happens when escaped content is escaped again on save. Fix the pipeline — only escape at the boundary that emits HTML — and use an HTML entity encoder/decoder to inspect suspicious strings locally.
Escaping untrusted text as HTML text/attributes is a correct default for plain text. It is not enough when you intentionally allow markup (Markdown, WYSIWYG, email HTML):
javascript: URLs and event handlers are not solved by < aloneUse a vetted sanitizer library for rich HTML. Use entity encoding for plain strings. Do not invent a half-escape that blocks <script> but allows <img onerror=…>.
Email clients are inconsistent. Named entities for common symbols are widely supported; exotic named entities may not be. Numeric references (…) are safer for unusual punctuation. Keep DOCTYPE and charset (UTF-8) correct so you are not forced into entity soup for ordinary Unicode — with UTF-8, you can often paste real characters and only escape the HTML syntax set.
Entities live in HTML text. MIME types describe how a payload should be interpreted end-to-end:
| Scenario | Risk if wrong |
|---|---|
Serving HTML as text/plain |
Entities show as literal source |
Serving user uploads as text/html |
Stored XSS |
Email multipart parts |
Wrong Content-Type / charset breaks Unicode |
| Clipboard / export "HTML" | Consumer may expect plain text |
When debugging "entities visible on screen" or "browser downloads instead of renders," check both escaping and the declared type. A quick MIME Type Lookup helps confirm that .html → text/html, .txt → text/plain, .csv → text/csv, and that you are not guessing from the file extension alone. Deep Content-Type header practice (uploads, APIs, charset parameters) deserves its own pass — the companion focus is headers and responses — but entity bugs and MIME mismatches often show up together in CMS and email work.
textContent / framework text binding (auto-escape).&: decode once; find the extra encode step.Use these codefunc tools alongside this guide:
Escape HTML syntax characters in the correct parsing context, use named or numeric entities for deliberate symbols, and fix double-encoding at the pipeline boundary. Entities are not a rich-text sanitizer. When content behaves like "wrong type" as much as "wrong escape," verify the media type too. For daily work, look up and transform entities in the browser with HTML Entity Lookup and HTML Entities, and confirm types with MIME Type Lookup — no data needs to leave your machine.
Learn when Base58 beats Base64 — alphabet rules, leading-zero handling, checksum variants, and how to encode or decode safely in the browser.
Break down URL parts, encode query values correctly, and know when to use encodeURIComponent vs encodeURI — plus reserved characters that break APIs.
Configure CSP for single-page apps — script-src with nonces and hashes, common React and Vite failures, CORS interplay, reporting, and a practical rollout checklist.
Find a developer tool