Automatically convert plain text URLs into link using jquery

Here I am going to introduce one very useful plugin in jquery to automatically convert plain text URLs into link using jquery. Some time you got text with lot’s of url’s and you need to automatically generate link from plain URLs so that visitor can easily goto source site. Here i found plugin urlToLink on github which help you to transforms URLs in text into HTML <a> elements.

Follow below steps to automatically convert plain text url’s into link using jquery

Include the latest version of jQuery library and jquery.urlToLink.min.js script in your html page.

<script src="" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
<script src="jquery.urlToLink.min.js"></script>

Sample html paragraph with some dummy URLs

<p style="width:70%; margin:0 auto;">
Lorem Ipsum ( ) is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. ( ) It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.<br/>
My Public NoteBook -

Finally call urlToLink to link function on page and convert all plain text url’s into links.

$(function() {  

If you want to open all links in new tab, you need to simply pass target attribute in above function see below example.

$(function() {  
   target : '_blank'

See live demo and download source code.


See official page for more information