Linkify is a JavaScript plugin for finding links in plain-text and converting them to HTML tags.
  • JavaScript 97.3%
  • HTML 2.1%
  • Shell 0.6%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
J. Ryan Stinnett ad5957ac0e v4.0.0-rc.6
2022-01-25 17:13:13 +00:00
.github/workflows Change default branch to main 2021-09-14 22:27:42 -04:00
packages v4.0.0-rc.6 2022-01-25 17:13:13 +00:00
tasks Script to automatically update tlds.js 2021-11-23 19:04:52 -05:00
test Unified Token Formatting and Rendering (#364) 2021-11-23 19:07:23 -05:00
.editorconfig v3.0 (#318) 2021-09-14 22:23:59 -04:00
.eslintignore v3.0 (#318) 2021-09-14 22:23:59 -04:00
.eslintrc Improved eslint eqeqeq rule 2021-11-22 23:29:17 -05:00
.gitignore v3.0 (#318) 2021-09-14 22:23:59 -04:00
.mocharc.yml v3.0 (#318) 2021-09-14 22:23:59 -04:00
.npmignore Add missing .npmignore 2021-09-14 23:01:27 -04:00
babel.config.js v3.0 (#318) 2021-09-14 22:23:59 -04:00
CHANGELOG.md v3.0.5 2022-01-03 09:51:28 -05:00
CONTRIBUTING.md Improved CONTRIBUTING guide 2021-09-15 19:32:16 -04:00
LICENSE Update LICENSE year 2021-09-14 22:27:52 -04:00
package-lock.json Regenerate package-lock.json 2022-01-03 10:11:43 -05:00
package.json Merge branch 'main' into v4.0 2022-01-03 10:08:44 -05:00
README.md Fix README demo link and example output 2021-09-15 19:41:48 -04:00
rollup.config.js Fix externals 2022-01-20 15:42:39 +00:00

Linkify

npm version CI BrowserStack Status Coverage Status

Linkify is a JavaScript plugin. Use Linkify to find links in plain-text and convert them to HTML <a> tags. It automatically highlights URLs, #hashtags, @mentions and more.

Jump to

Features

  • Detect URLs and email addresses
  • #hashtag, @mention and #-ticket plugins
  • React and jQuery support
  • Multi-language and emoji support
  • Custom link plugins
  • Fast, accurate and small footprint (~30kB minified, ~15kB gzipped)
  • 99% test coverage
  • Compatible with all modern browsers (Internet Explorer 11 and up)

Demo

Launch demo

Installation and Usage

View full documentation.

Download the latest release for direct use in the browser, or install via NPM:

npm install linkifyjs linkify-html

Quick Start

When developing in an environment with JavaScript module loader such as Webpack, use an import statement:

import * as linkify from 'linkifyjs';
import linkifyHtml from 'linkify-html';

Or in Node.js with CommonJS modules

const linkify = require('linkifyjs');
const linkifyHtml = require('linkify-html');

Note: When linkify-ing text that does not contain HTML, install and use the linkify-string package instead of linkify-html. Read more about Linkify's interfaces.

Usage

const options = { defaultProtocol: 'https' };
linkifyHtml('Any links to github.com here? If not, contact test@example.com', options);

Returns the following string:

'Any links to <a href="https://github.com">github.com</a> here? If not, contact <a href="mailto:test@example.com">test@example.com</a>'

To modify the resulting links with a target attribute, class name and more, use the available options.

linkify.find('Any links to github.com here? If not, contact test@example.com');

Returns the following array

[
  {
    type: 'url',
    value: 'github.com',
    isLink: true,
    href: 'http://github.com',
    start: 13,
    end: 23
  },
  {
    type: 'email',
    value: 'test@example.com',
    isLink: true,
    href: 'mailto:test@example.com',
    start: 46,
    end: 62
  }
]

Check if as string is a valid URL or email address:

linkify.test('github.com'); // true

Check if a string is a valid email address:

linkify.test('github.com', 'email'); // false
linkify.test('noreply@github.com', 'email'); // true

Usage with React, jQuery or the browser DOM

Read the interface documentation to learn how to use linkify when working with a specific JavaScript environment such as React.

Plugins for @mentions, #hashtags and more

By default Linkify will only detect and highlight web URLs and e-mail addresses. Plugins for @mentions, #hashtags and more may be installed separately. Read the plugin documentation.

Browser Support

Linkify natively supports all modern browsers. Linkify is tested on Internet Explorer 11 and above.

Node.js Support

Linkify is tested on Node.js 10 and up. Older versions are unofficially supported.

Downloads

Download the latest release

API Documentation

View full documentation at linkify.js.org/docs

Contributing

Check out CONTRIBUTING.md.

License

MIT

Authors

Linkify is made with ❤️ by Hypercontext and @nfrasser