Skip to content
Parsing tweets into lists of entities.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.


A JS module for parsing tweets into an array of entities.

Huge thanks go to Vincent Loy and his TweetParser.js project, for which the regexes this package uses were originally taken from. Vincent's project is great but works on tweets in the DOM, and I needed something that could take the raw text.

For example, given a tweet with this content:

Migrating from Angular to React- an honest case study on @songkick by @Jack_Franklin. Watch here-  #reactlondon

We get an array of entities:

  { type: 'TEXT', content: 'Migrating from Angular to React- an honest case study on ' },
    type: 'USER',
    content: '@songkick',
    url: '',
  { type: 'TEXT', content: ' by ' },
    type: 'USER',
    content: '@Jack_Franklin',
    url: '',
  { type: 'TEXT', content: '. Watch here- ' },
    type: 'LINK',
    content: '',
    url: '',
  { type: 'TEXT', content: '  ' },
    type: 'HASH',
    content: '#reactlondon',
    url: '',


A side project I was working on had to render tweets from an API and I wanted a nice way of being able to style different parts of the tweet based on if they were a link, hashtag, user reference or just plain text.

Installation and Usage

$ npm install tweet-parser

$ yarn add tweet-parser
import tweetParser from 'tweet-parser'

const result = tweetParser('My fun tweet');

// [ { type: 'TEXT', content: 'My fun tweet' } ]
You can’t perform that action at this time.