HTML Entity Encoder / Decoder

Convert special characters to HTML entities and back.

Input
Output
All examples use BASE_URL — set it to your deployment URL.
POST/api/html/encode
Convert special characters to HTML entities.
const BASE_URL = "http://localhost:3000"; const res = await fetch(`${BASE_URL}/api/html/encode`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ text: '<div class="test">&</div>' }) }); // → { success: true, result: "&lt;div class=&quot;test&quot;&gt;..." }
POST/api/html/decode
Decode HTML entities back to characters.
await fetch(`${BASE_URL}/api/html/decode`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ text: "&lt;p&gt;Hello&lt;/p&gt;" }) }); // → { success: true, result: "<p>Hello</p>" }