Written by: Geoffrey Callaghan
how to Obfuscated an Email address
How To Obfuscated An Email Address
Obfuscating an email address is a technique used to make it difficult for automated systems (bots) to harvest the email address while keeping it accessible to human users. There are several methods to obfuscate an email address, including using HTML character entities, JavaScript, or even image-based approaches. Here are some common techniques:
You can replace characters in the email address with their corresponding HTML entities. This makes it harder for bots to read the email address.
Example:
<!-- Original Email: example@example.com -->
<a href="mailto:example@example.com">example@example.com</a>
Using JavaScript to construct the email address in the browser ensures that bots that don’t execute JavaScript won’t see the email.
Example:
<!-- HTML -->
<span id="email"></span>
<script>
document.getElementById("email").innerHTML = "example" + "@" + "example.com";
document.getElementById("email").href = "mailto:example@example.com";
</script>
Encode the email address in base64 and decode it with JavaScript.
Example:
<!-- HTML -->
<a id="email-link" href="#">Email us</a>
<script>
const email = atob('ZXhhbXBsZUBleGFtcGxlLmNvbQ=='); // base64 encoded "example@example.com"
document.getElementById('email-link').setAttribute('href', 'mailto:' + email);
document.getElementById('email-link').innerText = email;
</script>
Split the email address and use CSS to piece it together.
Example:
<!-- HTML -->
<span class="email-part1">example</span>
<span class="email-part2">@example.com</span>
<style>
.email-part2::before {
content: '@';
}
</style>
As previously mentioned, you can use a service like Veilmail to handle the obfuscation for you. Here’s an example:
Steps:
Example:
<span class="veilmail">[email protected]</span>
<script src="https://veilmail.com/js/veilmail.js"></script>
Convert your email address into an image. This method makes it impossible for bots to scrape the email address, but it’s not very user-friendly since users cannot copy the email address easily.
Example:
<!-- HTML -->
<img src="path/to/email_image.png" alt="Email example@example.com">
Choosing the right method depends on your specific needs and the level of obfuscation you require. For most purposes, a combination of HTML character entities and JavaScript-based obfuscation should be sufficient to protect your email address from basic scraping bots while maintaining usability for your site’s visitors.
check out our hide email address from spammers tool VeilMail