A JavaScript parser for SubRip(.srt) files

Drop srt file(s)

Srt.js is a simple JavaScript parser for SubRip(.srt) files. You can easily parse a .srt subtitle file in the client side or in the server side using Node.js

$ git clone srtjs

Or you can just

Download from Github


Start based on CommonJS. You can use it in Node.js, Browserify or Webpack.

var Srt = require('./srt.js');
var srt = new Srt(yourSrtText);

You can get the content of a srt file using FileReader API


Srt object provides access to the lines:

// get the number of entries
console.log(srt.lines.length); // 723

// get the 5th line
console.log(srt.lines[4].subtitle); // Come on, let's go!

// get the index of the entry
console.log(srt.lines[4].counter); // 5

// get the start time of the 5th entry
console.log(srt.lines[5].start.text); // 00:01:42,500

// each entry also has a start and end date object

// you can get hours, minutes, seconds, and milliseconds as well


// move all subs 5 seconds later
srt.shift(5, seconds);

// move all subs 2 seconds earlier
srt.shift(-2, seconds);

Get .srt text

You can call getSrtContent() method to get the content as plain text.


You can create a download link using Data URI.

Srt.js is available under the MIT License.

Fork me on GitHub