Prevent Twitter from Converting @Mentions into Links

P
Published in: Twitter

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:

https://twitter.com/labnol/statuses/439413450821742593

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. https://www.youtube.com/watch?v=nmq908lqCmk

Published in: Twitter

Looking for something? Find here!

Meet the Author

Web Geek, Tech Columnist
A
Amit Agarwal

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

Get in touch