How to Encode an Email Address to Display on Web Pages

In this tutorial, I will demonstrate how you can encode your email address before putting on your website, in order to reduce spam emails that you receive.

As much as email communication is a huge convenience in our daily lives both in our personal relations and business relations, unwanted email spam is as much of an annoyance to anyone who receives a neverending flow of spam emails; that's pretty much everyone with an email address.

Even though the technology and legal procedures to fight with spam have considerably improved in the last decade, unfortunately spamming is still with us and it doesn't look like we will be completely getting rid of it anytime soon. As an average email account user, we can't prevent spam emails from originating, that is we can't prevent the spammer from sending the spam emails from their server. But we can do things to prevent that emails from landing in our email box.

In a previous tutorial, I showed a unique method for getting rid of spam emails, which is not a real solution but still would help a lot for reducing the annoyance the spam emails cause. Another thing you can do for receiving less spam emails, if not totally forgetting about them, is to protect your email address online, especially on web pages such as your website or company page where you publicly display your email address.

Though publicly displaying your email address is not a recommended practice, there are times where it makes more sense to provide a contact email address rather than a contact form on your contact page. In such cases, it will be nice if you added one layer of protection to your email address by encoding it, so that it will make it harder for the spammers to find your email address. Spammers are those people who scrape websites using special scripts to visit and scrape lots of websites to collect publicly displayed email addresses and then, not only send spam emails to them but also share those emails publicly, inviting other spammers on board.

Now, let's see how you can encode your email address before putting it on your website.

How to Encode an Email Address

Every character that you see on a web page such as the letters, numbers, special characters, signs and symbols are represented with special character codes defined by HTML. While creating your web page, you can use either the character itself or its character code as you wish. While the character will be displayed as the same when you open the page, when you look into the source code of the page, you will still see the difference in the code.

For example, the letter A is represented by A character code in HTML. If you put A or A into your web page, they will both display the same thing: A. But if you use A to display the letter A, when the code of the page is viewed, or "scraped" by a script, instead of letter A, the scraper will see the characters A. Though this is not a bulletproof way to prevent scrapers from finding your email address, it's still one layer of protective measure that you can do to keep the spammers at bay.

Encoded Email Address Example

The only thing you need to know to encode an email address is the corresponding codes for each character in your email address. Let's say we want to encode the following email address:

The encoded version of the above email address is as follows:

It's long and complicated, but that's the point, right? To make the email address scrapers job harder.

You can find the HTML code for all characters that you may use in your email address on the following page:

Once your encoded email address is ready, you can insert it on your web page. In the source code, the long and complicated encoded text will be visible but on the page itself, your email address will be visible.

f t g+ in