Registry / serialization / subtitles-parser

subtitles-parser

JSON →
library0.0.2jsnpmunverified

This package, `subtitles-parser`, is a very basic JavaScript module designed specifically for parsing SubRip (SRT) subtitle files within a Node.js environment. It provides synchronous methods to transform SRT content into a structured JavaScript object array, where each entry includes `id`, `startTime`, `endTime`, and `text`. It also offers functionality to convert this object array back into the SRT format. The package is exceptionally old, with its only notable version being 0.0.2, which was last published over a decade ago in October 2013. It relies solely on CommonJS syntax and does not offer modern features such as ECMAScript Modules (ESM) support or TypeScript typings. Given its age and complete lack of maintenance, it is considered abandoned and is generally not recommended for new development.

npm install subtitles-parser
INSTALL
IMPORT
SIG · SUBTITLES-PARSER
S
subtitles-parser
serializationjavascriptv0.0.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

parser
const parser = require('subtitles-parser');
import parser from 'subtitles-parser';
This package only supports CommonJS `require()`. Attempting to use ESM `import` will result in a runtime error.
fromSrt
const { fromSrt } = require('subtitles-parser'); // or parser.fromSrt(...)
import { fromSrt } from 'subtitles-parser';
The `fromSrt` function is a method on the default export. Direct named imports are not supported.
toSrt
const { toSrt } = require('subtitles-parser'); // or parser.toSrt(...)
import { toSrt } from 'subtitles-parser';
Similar to `fromSrt`, `toSrt` is a method of the main `parser` object, not a standalone named export for ESM usage.

This quickstart demonstrates how to parse a SubRip (SRT) subtitle file, convert time strings to milliseconds, and convert the parsed object back into SRT format using the CommonJS `require` syntax.

import * as fs from 'node:fs'; // Create a dummy SRT file for demonstration const srtContent = `1 00:00:02,000 --> 00:00:06,000 Subtitle 1.1 Subtitle 1.2 2 00:00:28,967 --> 01:30:30,958 Subtitle 2.1 Subtitle 2.2`; fs.writeFileSync('my.srt', srtContent, 'utf8'); // Load the parser (CommonJS style as required by the package) const parser = require('subtitles-parser'); // Load file into data variable const srt = fs.readFileSync('my.srt', 'utf8'); // Parse the SRT content const data = parser.fromSrt(srt); console.log('Parsed data (string times):', JSON.stringify(data, null, 2)); // Parse the SRT content, converting times to milliseconds const dataMs = parser.fromSrt(srt, true); console.log('\nParsed data (millisecond times):', JSON.stringify(dataMs, null, 2)); // Convert the object back to SRT format const convertedSrt = parser.toSrt(data); console.log('\nConverted back to SRT:\n', convertedSrt); // Clean up the dummy file fs.unlinkSync('my.srt');
Debug
Known issues
breakingThe `subtitles-parser` package is completely abandoned, with its last update over a decade ago (October 2013). This means there will be no further bug fixes, security patches, or compatibility updates for newer Node.js versions or JavaScript features.
fix
Avoid using this package for new projects. Consider actively maintained alternatives like `subtitle`, `simple-srt-parser`, or `@plussub/srt-vtt-parser` which offer better compatibility, features, and security.
affects: 0.0.2
gotchaThe package exclusively uses CommonJS (`require`) syntax and does not support ECMAScript Modules (ESM). Attempting to `import` it will result in a runtime error.
fix
Ensure your project is configured for CommonJS or use `require()` directly within an ESM context if supported by your build tooling. Always use `const parser = require('subtitles-parser');`.
affects: 0.0.2
gotchaThis package only supports the SubRip (SRT) subtitle format. It does not provide parsing or writing capabilities for other common formats like WebVTT, SSA/ASS, or MicroDVD.
fix
If you need to handle multiple subtitle formats, you will need to use a different, more comprehensive library or integrate multiple parsers for each specific format.
affects: 0.0.2
Errors
Common errors & fixes
SyntaxError: Cannot use import statement outside a module
Attempting to use `import` syntax with this CommonJS-only package in an ECMAScript Module environment.
fix
Replace `import parser from 'subtitles-parser';` with `const parser = require('subtitles-parser');`.
ReferenceError: parser is not defined
The `require` statement for the package was either omitted or assigned to a different variable name than 'parser'.
fix
Ensure you have `const parser = require('subtitles-parser');` at the top of your file before attempting to use `parser.fromSrt()` or `parser.toSrt()`.
Upgrade
Version history
0.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
12 hits · last 30 days
node
10
OpenAI (training)
1
Resources
subtitles-parser — npm install subtitles-parser · libregistry