m3u8-parser is a JavaScript library designed for parsing M3U8 HLS (HTTP Live Streaming) manifests. It provides a robust, standalone mechanism to interpret the structure and metadata of HLS playlists, converting them into a structured JavaScript object. Currently at version 7.2.0, the package maintains an active development pace, regularly incorporating support for new HLS tags and specifications, as evidenced by recent feature additions in minor releases (e.g., #EXT-X-I-FRAME-STREAM-INF, #EXT-X-I-FRAMES-ONLY, #EXT-X-DEFINE). Originating from the Video.js ecosystem, it has since become an independent utility, removing its direct dependency on Video.js in version 1.0.1. Its key differentiators include comprehensive HLS tag support, extensibility through custom parsers, and the ability to handle constructor options for advanced features like variable replacement with #EXT-X-DEFINE, making it suitable for both simple manifest interpretation and complex HLS stream management.
npm install m3u8-parserVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to instantiate the m3u8-parser, feed it an HLS manifest string, and access the resulting structured JavaScript object containing parsed playlist information. It shows basic manifest creation, parsing, and logging of key properties like endList status, target duration, and segment details.
Refer to the official release notes and changelogs for specific major versions when upgrading to understand breaking changes and necessary migration steps.
Supply an options object to the `Parser` constructor, e.g., `new m3u8Parser.Parser({ url: 'https://example.com/manifest.m3u8', mainDefinitions: { key: 'value' } });` when dealing with manifests using #EXT-X-DEFINE.Always check the 'Not Yet Supported' section in the README or library source for current limitations if your manifests use advanced or experimental HLS tags. Consider contributing custom parsers for unsupported tags if necessary.
Ensure `video.js` is explicitly included in your project's dependencies if your application still requires it and previously relied on `m3u8-parser` as a transitive dependency prior to version 1.0.1.
For CommonJS, ensure you use `const parser = new m3u8Parser.Parser();` after `const m3u8Parser = require('m3u8-parser');`. For ESM, use `import { Parser } from 'm3u8-parser'; const parser = new Parser();`.Validate the M3U8 manifest string for correct syntax, missing required tags, or unexpected characters. Refer to the HLS specification for proper manifest formatting.
Verify that `require('m3u8-parser')` (CommonJS), `import { Parser } from 'm3u8-parser'` (ESM), or a `<script>` tag loading the UMD build is present and executed correctly before attempting to use `m3u8Parser`.No dependency data recorded yet.