Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including srtjs with all npm packages installed. Try it out:

var srtjs = require("srtjs")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

srtjs v0.1.0

A JavaScript parser for .srt subtitle file


A small parser for SubRip(.srt) subtitle file in JavaScript

Online demo


npm install srtjs --save



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

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


// 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 subtitle text:



npm test


Srt.js is available under the MIT License.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free