Registry / serialization / ass-compiler

ass-compiler

JSON →
library0.1.16jsnpmunverified

Parses and compiles ASS/SSA subtitle format into an easy-to-use data structure. Current stable version: 0.1.16. Released as needed with minor fixes and enhancements. Key differentiators: provides both low-level parse/stringify and high-level compile/decompile with validation, tag merging, drawing transformation, and default style support. Ships TypeScript types. Alternatives require more manual parsing or lack validation.

serializationdata
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

ESM-only since v0.1.13; CommonJS require will not work with default import.

import { parse } from 'ass-compiler'

compile is a named export, not default. ESM-only.

import { compile } from 'ass-compiler'

Converts parsed JSON back to ASS text.

import { stringify } from 'ass-compiler'

Demonstrates parsing, compiling with options, and round-tripping ASS text using parse, compile, stringify, and decompile.

import { parse, compile, stringify, decompile } from 'ass-compiler'; const assText = `[Script Info] ScriptType: v4.00+ PlayResX: 384 PlayResY: 288 [V4+ Styles] Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding Style: Default,Arial,20,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,2,2,2,10,10,10,1 [Events] Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text Dialogue: 0,0:00:01.00,0:00:04.00,Default,,0,0,0,,Hello world! `; const parsed = parse(assText); console.log(parsed); const compiled = compile(assText, { defaultInfo: { PlayResX: 384, PlayResY: 288 }, defaultStyle: { Name: 'Default', Fontname: 'Arial', Fontsize: '20', PrimaryColour: '&H00FFFFFF&', SecondaryColour: '&H000000FF&', OutlineColour: '&H00000000&', BackColour: '&H00000000&', Bold: '0', Italic: '0', Underline: '0', StrikeOut: '0', ScaleX: '100', ScaleY: '100', Spacing: '0', Angle: '0', BorderStyle: '1', Outline: '2', Shadow: '2', Alignment: '2', MarginL: '10', MarginR: '10', MarginV: '10', Encoding: '1' } }); console.log(compiled); const backToText = stringify(parsed); const decompiledText = decompile(compiled); console.log(backToText === decompiledText);
Debug
Known footguns
breakingESM-only since v0.1.13; CommonJS require will not work.
gotchaThe first \r tag must be before other override tags; otherwise it can cause incorrect style resolution.
gotchaWhen multiple \pos or \move tags exist, only the first one is used; later ones are ignored.
gotchaTimestamps with rounding precision issues may cause slight time shifts; force rounding not applied.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
19 hits · last 30 days
bytedance
4
gptbot
3
ahrefsbot
3
claudebot
3
bingbot
1
Resources