Registry / serialization / subtitles-parser-vtt

subtitles-parser-vtt

JSON →
library0.1.0jsnpmunverified

This package, `subtitles-parser-vtt`, is a Node.js module designed to parse and convert SubRip (SRT) subtitle files. Despite having `vtt` in its name, it explicitly handles the SubRip (.srt) format for both parsing into a JavaScript object and converting an object back into SRT format. The current and only stable version is `0.1.0`, published in 2015. Given its age and lack of updates, the package is considered abandoned. It offers basic functionality to convert SRT timestamps to milliseconds, differentiating itself from more actively maintained, feature-rich subtitle parsers that often support multiple formats (like WebVTT), streaming APIs, and TypeScript typings.

npm install subtitles-parser-vtt
INSTALL
IMPORT
SIG · SUBTITLES-PARSER-V
S
subtitles-parser-vtt
serializationjavascriptv0.1.0
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-vtt');
import parser from 'subtitles-parser-vtt';
This package is a CommonJS module and does not support ES Modules natively. Use `require`.
fromVtt
const data = parser.fromVtt(srtContent);
import { fromVtt } from 'subtitles-parser-vtt';
The `fromVtt` function is a method on the default `parser` object, not a named export. It parses SRT content, despite the method name.
toVtt
const srtOutput = parser.toVtt(dataObject);
import { toVtt } from 'subtitles-parser-vtt';
The `toVtt` function is a method on the default `parser` object, not a named export. It converts an object back to SRT content.

This quickstart demonstrates parsing SubRip (SRT) content from a string, showing both string and millisecond timestamp outputs, and converting the parsed object back into SRT format using the `fromVtt` and `toVtt` methods.

const fs = require('fs'); const parser = require('subtitles-parser-vtt'); // 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`; // In a real application, you would read from a file: // const srt = fs.readFileSync('my.srt', 'utf8'); // Parse the SRT content const parsedData = parser.fromVtt(srtContent); console.log('Parsed data (string timestamps):', parsedData); // Parse with millisecond timestamps const parsedDataMs = parser.fromVtt(srtContent, true); console.log('Parsed data (millisecond timestamps):', parsedDataMs); // Convert parsed data back to SRT format const convertedSrt = parser.toVtt(parsedData); console.log('\nConverted SRT content:\n', convertedSrt);
Debug
Known issues
gotchaThe package name `subtitles-parser-vtt` is misleading; this library is designed to parse SubRip (SRT) files, not WebVTT (.vtt) files. The documentation and internal functionality are explicitly for SRT.
fix
Be aware that this package handles SRT. If you need WebVTT parsing, consider alternatives like `subtitle` or `srt-vtt-parser`.
affects: >=0.1.0
breakingThis package is effectively abandoned, with its last update in 2015 and current version `0.1.0`. It is not maintained, which means it will not receive bug fixes, security updates, or new features.
fix
For active development, consider using modern, maintained subtitle parsing libraries that support both SRT and VTT, such as `subtitle` (which has TypeScript support and a streaming API) or `@polyflix/vtt-parser` (for VTT specifically).
affects: >=0.1.0
gotchaThis package is a CommonJS module (`require`) and does not natively support ES Modules (`import`). Using `import` statements directly will result in errors in an ESM-only project.
fix
For ES Module projects, you can use dynamic `import()` or configure your build tools (like Webpack or Rollup) to handle CommonJS modules. Alternatively, migrate to a modern library with native ESM support.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: parser.fromVtt is not a function
Attempting to use `fromVtt` or `toVtt` as a named import or directly from the `require` call, when it's a method on the default exported object.
fix
Ensure you are calling the methods on the `parser` object: `const parser = require('subtitles-parser-vtt'); parser.fromVtt(srt);`
Error: Cannot find module 'subtitles-parser-vtt'
The package has not been installed or the path is incorrect.
fix
Run `npm install subtitles-parser-vtt` to install the package.
SyntaxError: Unexpected token 'export'
Trying to use `import` syntax in a CommonJS environment, or using `require` in an ES Module context for this specific package.
fix
Ensure your project is configured for CommonJS (`"type": "commonjs"` in package.json or no `type` field) or use `require` syntax. If you are in an ESM project, consider `import parser from 'subtitles-parser-vtt'` (which might still require a transpiler or be wrapped) or migrate to a native ESM subtitle parser.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
subtitles-parser-vtt — npm install subtitles-parser-vtt · libregistry