{"id":24923,"library":"ass-compiler","title":"ASS Compiler","description":"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.","status":"active","version":"0.1.16","language":"javascript","source_language":"en","source_url":"https://github.com/weizhenye/ass-compiler","tags":["javascript","ass","ssa","subtitle","compiler","parser","typescript"],"install":[{"cmd":"npm install ass-compiler","lang":"bash","label":"npm"},{"cmd":"yarn add ass-compiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add ass-compiler","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only since v0.1.13; CommonJS require will not work with default import.","wrong":"const parse = require('ass-compiler').parse","symbol":"parse","correct":"import { parse } from 'ass-compiler'"},{"note":"compile is a named export, not default. ESM-only.","wrong":"import compile from 'ass-compiler'","symbol":"compile","correct":"import { compile } from 'ass-compiler'"},{"note":"Converts parsed JSON back to ASS text.","wrong":"","symbol":"stringify","correct":"import { stringify } from 'ass-compiler'"}],"quickstart":{"code":"import { parse, compile, stringify, decompile } from 'ass-compiler';\n\nconst assText = `[Script Info]\nScriptType: v4.00+\nPlayResX: 384\nPlayResY: 288\n\n[V4+ Styles]\nFormat: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding\nStyle: Default,Arial,20,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,2,2,2,10,10,10,1\n\n[Events]\nFormat: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text\nDialogue: 0,0:00:01.00,0:00:04.00,Default,,0,0,0,,Hello world!\n`;\n\nconst parsed = parse(assText);\nconsole.log(parsed);\n\nconst compiled = compile(assText, {\n  defaultInfo: { PlayResX: 384, PlayResY: 288 },\n  defaultStyle: {\n    Name: 'Default',\n    Fontname: 'Arial',\n    Fontsize: '20',\n    PrimaryColour: '&H00FFFFFF&',\n    SecondaryColour: '&H000000FF&',\n    OutlineColour: '&H00000000&',\n    BackColour: '&H00000000&',\n    Bold: '0',\n    Italic: '0',\n    Underline: '0',\n    StrikeOut: '0',\n    ScaleX: '100',\n    ScaleY: '100',\n    Spacing: '0',\n    Angle: '0',\n    BorderStyle: '1',\n    Outline: '2',\n    Shadow: '2',\n    Alignment: '2',\n    MarginL: '10',\n    MarginR: '10',\n    MarginV: '10',\n    Encoding: '1'\n  }\n});\nconsole.log(compiled);\n\nconst backToText = stringify(parsed);\nconst decompiledText = decompile(compiled);\nconsole.log(backToText === decompiledText);","lang":"typescript","description":"Demonstrates parsing, compiling with options, and round-tripping ASS text using parse, compile, stringify, and decompile."},"warnings":[{"fix":"Use ESM imports: import { parse } from 'ass-compiler'.","message":"ESM-only since v0.1.13; CommonJS require will not work.","severity":"breaking","affected_versions":">=0.1.13"},{"fix":"Ensure \\r appears at the start of override tags in Dialogue text.","message":"The first \\r tag must be before other override tags; otherwise it can cause incorrect style resolution.","severity":"gotcha","affected_versions":">=0.1.10"},{"fix":"Remove duplicate \\pos/\\move tags; keep only the first.","message":"When multiple \\pos or \\move tags exist, only the first one is used; later ones are ignored.","severity":"gotcha","affected_versions":">=0.1.15"},{"fix":"Upgrade to v0.1.11+ which fixes rounding via #16.","message":"Timestamps with rounding precision issues may cause slight time shifts; force rounding not applied.","severity":"gotcha","affected_versions":"<=0.1.10"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Provide a defaultStyle option including Fontname, or add a 'Default' style in the ASS file.","cause":"Default style not defined in ASS file and no defaultStyle option provided.","error":"TypeError: Cannot read properties of undefined (reading 'Fontname')"},{"fix":"Ensure all brackets are balanced; update to v0.1.15+ which better handles mismatched brackets.","cause":"ASS text contains mismatched brackets (e.g., unclosed { or }).","error":"SyntaxError: Invalid or unexpected token"},{"fix":"Switch to ESM imports (import { parse } from 'ass-compiler') or downgrade to v0.1.12.","cause":"Trying to require() the package with CommonJS after v0.1.13.","error":"ERR_REQUIRE_ESM"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}