Jump To

Linkify HTML String Interface

Use linkify-html to highlight links within strings that contain HTML markup.

Installation

Node.js module

Install from the command line with NPM

npm install linkifyjs linkify-html

Import into your JavaScript with require

const linkifyHtml = require("linkify-html");

or with ES modules

import linkifyHtml from "linkify-html";

Browser globals

Download linkify and extract the contents into your website’s assets directory. Include the following scripts in your HTML:

<script src="linkify.js"></script>
<script src="linkify-html.js"></script>

Usage

const options = {
  /* … */
};
const str = "<p>For help with GitHub.com, please email support@github.com</p>";
linkifyHtml(str, options);

Returns

'<p>For help with <a href="http://github.com" target="_blank">GitHub.com</a>, please email <a href="mailto:support@github.com">support@github.com</a></p>';

Params

  • string str string to linkify
  • Object [options] Options object

Returns string Linkified HTML string