node package manager


Convert a tweet into HTML, parsing out #hashtags, @mentions and


Convert a tweet into HTML, parsing out #hashtags, @mentions and Uses the official twitter-text npm package for parsing.

var htmlTweet = require('html-tweet')()

var html = htmlTweet('Hello #world, this is a @mention and a')

// html => "Hello <a href='#'>#world</a>, this is a <a href='#'>@mention</a> and a <a href='#'></a>"
var htmlTweet = require('html-tweet')()

Returns a HTML version of the tweet text.

Options can be passed to require with template strings for the hashtags, urls and mentions. Uses lodash/underscore template strings: <a href='#'><%= hashtag %></a>.

Options are as follows:

  • hashtag - hashtag template string
  • default: <a href='#'><%= hashtag %></a>
  • mention - mention template string
  • default: <a href='#'><%= mention %></a>
  • url - url template string
  • default: <a href='#'><%= url %></a>


var htmlTweet = require('html-tweet')(
  { hashtag: '<a class=\'hashtag\' href=\'#\'><%= hashtag %></a>'
  , mention: '<a class=\'mention\' href=\'#\'><%= mention %></a>'
  , url: '<a class=\'url\' href=\'#\'><%= url %></a>'
npm install html-tweet