🔹 What is it?
An HTML Entity Encoder/Decoder converts special characters in your text (like £, ©, 🎓, ✓, <, >, ", ') to their HTML-safe versions and vice versa.
🔹 Why use it?
✅ Prevents encoding issues (like ?? in emails or web pages)
✅ Ensures symbols display correctly across all devices/email clients
✅ Protects HTML content from breaking (especially when sending through PHPMailer or storing in databases)
Online Link: https://codepen.io/Web-Offers/pen/ogXKMbM
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HTML Entity Encoder/Decoder</title>
<style>
body { font-family: Arial, sans-serif; padding: 20px; max-width: 600px; margin: auto; }
textarea { width: 100%; height: 100px; margin-bottom: 10px; }
button { padding: 10px 15px; margin-right: 10px; }
label { font-weight: bold; }
</style>
</head>
<body>
<h2>HTML Entity Encoder / Decoder</h2>
<label for="inputText">Input:</label>
<textarea id="inputText"></textarea>
<div>
<button onclick="encodeHTML()">Encode</button>
<button onclick="decodeHTML()">Decode</button>
</div>
<label for="outputText">Output:</label>
<textarea id="outputText" readonly></textarea>
<script>
function encodeHTML() {
const input = document.getElementById("inputText").value;
const encoded = input.replace(/[\u00A0-\u9999<>\&]/gim, function(i) {
return '&#'+i.charCodeAt(0)+';';
});
document.getElementById("outputText").value = encoded;
}
function decodeHTML() {
const input = document.getElementById("inputText").value;
const textarea = document.createElement("textarea");
textarea.innerHTML = input;
document.getElementById("outputText").value = textarea.value;
}
</script>
</body>
</html>
0 Comments