
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
srt-parser-2
Advanced tools
An SRT parser for Javascript.
It reads an .srt file into an array.
npm
npm install srt-parser-2
or yarn
yarn add srt-parser-2
This is a srt format file:
1
00:00:11,544 --> 00:00:12,682
Hello
it would become:
[{
id: '1',
startTime: '00:00:11,544',
startSeconds: 11.544,
endTime: '00:00:12,682',
endSeconds: 12.682,
text: 'Hello'
}]
Since it only process text,
it should work in both Browser and Node.js enviroment
let srt = `
1
00:00:11,544 --> 00:00:12,682
Hello
`;
import srtParser2 from "srt-parser-2";
var parser = new srtParser2();
var srt_array = parser.fromSrt(srt);
console.log(srt_array);
// turn array back to SRT string.
var srt_string = parser.toSrt(srt_array);
console.log(srt_string);
You can run this example using node example/1.Comma.js
npx srt-parser-2 -i input.srt -o output.json --minify
Options:
| Option | Required | Default |
|---|---|---|
| --input or -i | Yes | |
| --output or -o | No | output.json |
| --minify | No | false |
MIT
Why this one special? There are plently SRT parser on npm:
Nothing wrong.
All of them can handle this format:
1
00:00:11,544 --> 00:00:12,682
Hello
00:00:11.544
This is wrong format, it use period as separator
Or this:
00:00:11,5440
This is also wrong format, millisecond has 4 digit (should be 3)
Or this:
1:00:11,5
Similiar, hour & millisecond is only 1 digit (wrong)
Or this
00:00:00.05
etc
| Format | Other parser | srt-parser-2 | srt-parser-2 would turn this into |
|---|---|---|---|
| 00:00:01,544 | Yes :white_check_mark: | Yes :white_check_mark: | 00:00:01,544 |
| 00:00:01.544 | :question: Yes for some of them | Yes :white_check_mark: | 00:00:01,544 |
| 00:00:01.54 | :question: Yes for some of them | Yes :white_check_mark: | 00:00:01,544 |
| 00:00:00.3333 | No :x: | Yes :white_check_mark: | 00:00:00,333 |
| 00:00:00.3 | No :x: | Yes :white_check_mark: | 00:00:00,300 |
| 1:2:3.4 | No :x: | Yes :white_check_mark: | 01:02:03,400 |
Basic principle:
.(periods) or ,(comma), periods(incorrect) will be replace with comma(correct)FAQs
Parse SRT into array
The npm package srt-parser-2 receives a total of 53,981 weekly downloads. As such, srt-parser-2 popularity was classified as popular.
We found that srt-parser-2 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.