Prevent Twitter from Converting @Mentions into Links

Twitter

If your tweet contains two words that are separated by a dot (or period), Twitter may sometimes interpret that combination as a web address and will auto-convert the words into a clickable hyperlink wrapped inside a t.co URL.

Similarly, if you add the ”@” symbol before any word in a tweet, Twitter may see that as a mention and will automatically link that word to a Twitter profile. And words starting with the # hash sign are converted into links pointing to search results as well.

These auto-generated links are useful in most cases but sometimes you may just want twitter to display your tweets in plain text and not convert words into links. For instance, see this tweet:

It includes the same text (labnol.org) twice but in the first case, Twitter is pointing to a website and in the other case, it’s pointing to a Twitter profile.

The trick is simple

If you would like to prevent Twitter from interpreting two consecutive words as a URL, just add a zero width space after the dot. Similarly, if you would not like Twitter to auto-convert @mentions or #tags into hyperlinks, add a zero width space after the @ or # symbol respectively.

How to Insert Zero Width Space in Tweets

The HTML code for zero width space is  but you cannot add HTML codes directly inside Twitter so here’s a simple workaround.

<p>
  Enter text:
  <input
    id="tweet"
    onkeyup="document.getElementById ('result').innerHTML='<br />'+this.value.replace(/([@#\.])/ig, '$1&#8203;');"
    type="text"
  />
  <span id="result" style="background:lightyellow"></span>
</p>

Enter some text in the input box above and it will automatically add zero width space after every dot, #hash or @mention. You can then copy-paste the converted text into you Twitter and none of the words will ever get converted into hyperlinks.

youtube: https://www.youtube.com/watch?v=nmq908lqCmk

Amit Agarwal is a web geek, solo entrepreneur and loves making things on the Internet. Google recently awarded him the Google Developer Expert and Google Cloud Champion title for his work on Google Workspace and Google Apps Script.

Awards & Recognition

Google Developer Expert

Google Developer Expert

Google awarded us the Developer Expert title recogizing our work in Workspace

ProductHunt Golden Kitty

ProductHunt Golden Kitty

Our Gmail tool won the Lifehack of the Year award at ProductHunt Golden Kitty Awards

Microsoft MVP Alumni

Microsoft MVP Alumni

Microsoft awarded us the Most Valuable Professional title for 5 years in a row

Google Cloud Champion

Google Cloud Champion

Google awarded us the Champion Innovator award for technical expertise

Want to stay up to date?
Sign up for our email newsletter.

We will never send any spam emails. Promise 🫶🏻