How to convert plain text links to hyperlinks (urls) in JavaScript?

Make plain links clickable – convert plain text links to URLs.

Linkify: convert plain text links to html A tags

Linkify is a zero-dependency JavaScript library for finding links in plain-text and converting them to HTML ‘a’ tags. We can turn text address to clickable links using JS code.

Key features

Speed – Each string is analyzed exactly once to detect every kind of linkable entity.

Accuracy – Linkify uses a (close to) complete list of valid top-level domains to ensure that only valid URLs and email addresses are matched.

Extensibility – Linkify is designed to be fast and lightweight, but comes with a powerful plugin API that lets you detect even more information like #hashtags and @mentions.

Modern implementation – Linkify is written in ECMAScript6 and compiles to ES5 for modern JavaScript runtimes.

Small footprint – Linkify and its jQuery interface clock in at approximately 15KB minified (5KB gzipped) – approximately 50% the size of Twitter Text

Cross-browser – Linkify is compatible with all modern browsers, as well as Internet Explorer 9 and up.

Linkify - turn plain text urls into clickable links!
Linkify – turn plain text urls into clickable links!

Setup

npm install --no-optional linkifyjs

or

yarn add --ignore-optional linkifyjs

or

bower install linkifyjs

Sample

// Find all links and convert them to anchor tags
$('p').linkify();
$('#sidebar').linkify({
  target: "_blank"
});

// Find all links in the given string
linkify.find('Any links to google.com here?');

License: MIT

Homepage

https://soapbox.github.io/linkifyjs/

GitHub

https://github.com/SoapBox/linkifyjs

See also

TagCanvas – HTML5 canvas tag cloud

tx3TagCloud – very simple tag cloud jQuery plugin

JSON data with colored syntax – pretty-print-json

Enjoy!