HTML Encoder Online
Quick answer
Paste markup or text and convert it in both directions: encoding turns <, >, &, quotes and apostrophes into HTML entities so code displays as text, and decoding restores every named or numeric character reference back to real characters. Everything runs in your browser — no upload, no signup, no limits.
Last updated: October 26, 2026
HTML entities exist for one reason: some characters mean something to the browser. A < starts a tag, an & starts a reference, a quote ends an attribute — so the moment you want any of them to display as plain characters, you have to escape them. This encoder does that in one click, and its Decode tab runs the conversion backwards with the browser's own, complete entity table, so even obscure references like — or — come back as the characters they represent. It is the same loop you repeat while writing tutorials, building code-block previews, sanitizing editor output or debugging escaped JSON-in-HTML payloads — except here nothing leaves your machine, because conversion is pure string work done locally as you type.
Use the tool belowHTML Entity Encoder and Decoder runs entirely in your browser, nothing you paste or type is uploaded to any server, and no account is needed.
Worked examples
Real input on the left, exactly what HTML Entity Encoder and Decoder gives back on the right. Paste either side into the tool to re-create it.
1Encode: markup that must display as text
A documentation snippet that shows an actual div with attributes. Encoding the five dangerous characters keeps the browser from building a real element out of it.
<div class="greeting">
<p>Tom & Jerry said "hi" — it's 5 o'clock</p>
</div><div class="greeting">
<p>Tom &amp; Jerry said "hi" — it's 5 o'clock</p>
</div>Ampersands are escaped first, so an input that already contains & comes out as &amp; instead of double-decoding. The em-dash passes through untouched in named mode — it is display-safe; numeric mode would emit —.
2Decode: restoring escaped text to characters
The reverse job — a payload of references pulled from a CMS export, an API response or a feed, restored to readable text.
<p class="note">Copyright © 2026 — A &amp; B's guide</p><p class="note">Copyright © 2026 — A & B's guide</p>Decoding understands named and numeric forms interchangeably — ©, © and © all become ©. That is the browser's own reference table at work, not a hardcoded list.
How do I encode or decode HTML entities online?
- 1
Pick the direction with the Encode / Decode switch. Encoding escapes special characters into entities; decoding turns entities back into real characters.
- 2
Paste your text into the input pane. Conversion is live — the result appears in the output pane as you type, with no submit button to wait for.
- 3
When encoding, choose the entity style: named references (< & ") for readable output, or numeric (< plus all non-ASCII) when a strict ASCII-only or XML-safe result is required.
- 4
Copy the output with one click, save it as a file, or press Swap to move the result into the input and flip direction — the fastest way to sanity-check a round trip.
What this HTML encoder does well
Both directions, one surface
Encode escapes the five markup-critical characters; Decode restores any named or numeric reference, from & to 😀. The Swap button chains the two so you can verify that encode-then-decode returns your original text byte for byte.
Decoding with the browser's own entity table
Decode uses the HTML parser built into your browser — the same table of 2,200+ named references the HTML Standard defines. There is no hand-written lookup to go stale, so references like   or ‌ decode correctly even though no small tool could reasonably list them.
Named for readability, numeric for strictness
Named output (&lt;) stays human-readable and is what tutorials and docs expect. Numeric output (<, plus — for every non-ASCII character) produces a pure-ASCII result that survives old pipelines, XML contexts and charset-naive transports unchanged.
Live conversion with no submit step
Output updates as you paste and type, debounced through React's deferred rendering so large pastes stay smooth. The paste-glance-adjust-copy loop takes seconds, which matters when you are escaping dozens of snippets in a row.
Private by architecture
Conversion is string manipulation in your own tab. There is no upload endpoint, no server-side processing and no history: proprietary templates, internal error messages and unreleased copy can be escaped without the text ever leaving the device.
Escaping that respects the five dangerous characters
Encoding always covers & first (so &lt; does not double-encode), then <, >, quotes and apostrophes — the character set that is dangerous in both element text and attribute values. Everything else passes through untouched, so your formatting and Unicode stay exactly as they were.
HTML entities vs URL encoding vs JavaScript escaping
Three different "escape" systems get mixed up daily, and pasting output from the wrong one is a classic bug. This tool does the HTML row only — on purpose.
| System | Escapes for | Looks like | This tool |
|---|---|---|---|
| HTML entities | The HTML parser (element text and attribute values) | < & — | Yes — Encode and Decode tabs |
| URL / percent-encoding | URLs and query strings | %3C %26 | No — it would corrupt URLs; use encodeURIComponent in JS |
| JavaScript string escapes | JS string literals | \u003C \x26 \n | No — use JSON.stringify for JS string safety |
Rule of thumb: entities protect markup, percent-encoding protects URLs, \u escapes protect string literals. They are not interchangeable — an entity pasted into a URL is just text that happens to decode in the browser's lenient fallback.
What HTML entities are and why they exist
An HTML document is text that doubles as code: angle brackets open elements, ampersands open references, quotes delimit attributes. The moment any of those characters should be displayed rather than interpreted, the document needs a way to say "this is data, not markup" — and that way is the character reference, written either by name (<, &, ") or by codepoint (<, &). When the browser meets < inside element text it renders a literal < instead of starting a tag. That single mechanism is what lets every tutorial on the web show source code, what lets a comment form accept the text <script> without executing it, and what lets HTML carry math like a < b intact.
Escaping matters in two very different jobs. The defensive job is security: any untrusted string — form input, URL parameters, database rows — must be escaped before it is placed into HTML output, or a user can inject markup that the browser will happily execute. The presentational job is documentation: showing markup as text inside a page, code sample or tutorial. This tool serves both, but it is worth being precise about the boundary: encoding characters is not sanitization. It renders potentially dangerous input harmless in one context (element text), while a real sanitizer parses the document and removes dangerous constructs entirely.
Named vs numeric character references
Named references are words the HTML Standard defines, like © for ©, — for — and for a non-breaking space. They are readable and self-documenting, which is why hand-written HTML and most CMS content favors them. Numeric references write the Unicode codepoint directly: © or © is the same character as ©, and any codepoint can be written this way even when no name exists — the medal emoji 🎖 has no short memorable name, but 🎖 renders it everywhere. Numeric form is also the only option when you need guaranteed ASCII output, because every reference it produces is itself pure ASCII.
The practical split: use named for the handful you can type from memory (& < > " ©) and numeric for everything a pipeline might mangle. One quirk worth knowing: in HTML, the apostrophe has no memorable legacy name — ' was only added in XML and later HTML5 — which is why this encoder, like most server-side frameworks, writes '. It is the maximally compatible form, understood by every HTML and XML parser back to the 1990s.
Where encoding belongs — and where it does not
Escape at the last moment, in the output context, is the rule professionals follow. A string that will become HTML gets encoded as it is written into the template (modern frameworks do this by default — React's JSX, Angular interpolation and Vue's mustaches all escape automatically); a string that will become a URL gets percent-encoded; a string that will become SQL gets parameterized. The bug pattern is escaping at the wrong layer: storing pre-escaped text in the database leads to &amp; rendering to users, and double-escaping is the most common entity bug in the wild. If your decoded output still contains visible entities like <, the text was encoded twice — run Decode once more to check.
There is also a context where you should not encode at all: inside <script> and <style> blocks, entity references are not parsed, so < stays literally four characters and breaks your JavaScript. JSON payloads embedded in HTML are protected instead by escaping the sequence that could close the tag — replacing < with \u003C inside the JSON — which is exactly what JSON.stringify produces for such contexts. When in doubt about what a payload will do once it lands in a page, paste it into the HTML tester and watch the console; the renderer will tell you faster than any rule of thumb.
Questions this tool answers
- html encoder online
- html decoder online
- escape html online
- html entities encoder
- unescape html online
- html escape online
Frequently asked questions
Related HTML and JSON tools
HTML Tester Online
Render pasted markup and catch silent console errors
View HTML Source
Every method for reading a page's real source code
HTML Editor
Write and preview markup with live rendering
JSON Stringify Online
The JSON-side escape: \u003C, quotes and newlines
Code Beautifier
Re-indent escaped or minified HTML, CSS and JS