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.

Amit Agarwal

Amit Agarwal

Google Developer Expert, Google Cloud Champion

Amit Agarwal is a Google Developer Expert in Google Workspace and Google Apps Script. He holds an engineering degree in Computer Science (I.I.T.) and is the first professional blogger in India.

Amit has developed several popular Google add-ons including Mail Merge for Gmail and Document Studio. Read more on Lifehacker and YourStory

Awards & Titles

Digital Inspiration has won several awards since it's launch in 2004.

Google Developer Expert

Google Developer Expert

Google awarded us the Google Developer Expert award recogizing our work in Google Workspace.

ProductHunt Golden Kitty

ProductHunt Golden Kitty

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

Microsoft MVP Alumni

Microsoft MVP Alumni

Microsoft awarded us the Most Valuable Professional (MVP) title for 5 years in a row.

Google Cloud Champion

Google Cloud Champion

Google awarded us the Champion Innovator title recognizing our technical skill and expertise.

Email Newsletter

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

We will never send any spam emails. Promise.