Parser, serializer, and validator for the XLRC lyric format.
XLRC extends LRC with inline translations, furigana, word-level timing, and multi-voice attribution while staying plain-text and friendly to existing LRC tooling.
npm install @boof2015/xlrcimport { parseXLRC, serializeXLRC, validateXLRC } from "@boof2015/xlrc";
const source = `[ti:Example]
[lang:ja]
[00:12.40]私[わたし]が歌[うた]う
[>en]I sing
`;
const file = parseXLRC(source);
console.log(file.lines[0]?.text);
// "私が歌う"
console.log(file.lines[0]?.furigana);
// [{ start: 0, end: 1, base: "私", reading: "わたし", line: 4 }, ...]
const result = validateXLRC(file);
console.log(result.valid);
// true
const xlrc = serializeXLRC(file);Parses an XLRC string into structured metadata, lyric lines, translations, word timings, furigana, and parser warnings. Malformed input is non-fatal; warnings are returned on file.warnings.
For each parsed lyric line:
textis the clean display text with word timing and furigana markup removed.sourceTextis the lyric text after word timing tags are removed, with furigana markup preserved.rawTextis the original lyric body after the line timestamp and optional voice tag.voiceis a string label ornullwhen the line is unattributed.
Furigana entries refer to contiguous kanji spans in text. Kana around the span is left as normal display text, so 食[た]べる renders ruby over 食 and leaves べる untouched.
Serializes a structured XLRC object to canonical XLRC text.
Validates structured XLRC data and returns warnings for invalid metadata, timestamps, translations, furigana, and word timing data.
npm install
npm run typecheck
npm test
npm run buildThe package publishes built files from dist/ and generated TypeScript declarations. Runtime source is browser-compatible and has no runtime dependencies.
npm version patch
npm publish --access publicprepublishOnly runs typechecking, tests, and the production build before npm publishes the package.