JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 15
  • Score
    100M100P100Q72231F
  • License MIT

Convert ElevenLabs word-level JSON transcripts into clean, readable SRT subtitles

Package Exports

  • subchunk
  • subchunk/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (subchunk) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

subchunk

Convert ElevenLabs transcript JSON into clean, readable subtitles (.srt / .vtt).


🚨 Problem

ElevenLabs provides SRT exports, but they often look like this:

1
00:00:00,000 --> 00:00:05,000
This is a very long subtitle line that contains too many words and is hard to read quickly.

❌ Issues:

  • Subtitles are too long
  • Poor readability
  • Weak alignment with speech timing
  • Not optimized for modern content (Reels, Shorts, YouTube)

βœ… Solution

ElevenLabs JSON includes word-level timestamps β€” this tool uses that to generate high-quality subtitles:

βœ” Short, readable chunks βœ” Pause-aware timing βœ” Smart sentence splitting βœ” Multi-line subtitles (2 lines max) βœ” Speaker labels (optional) βœ” .srt and .vtt support


✨ Example Output

1
00:00:00,460 --> 00:00:01,160
Three minutes.

2
00:00:01,200 --> 00:00:02,400
That’s all it takes
to get started.

βš™οΈ Features

  • 🎯 Smart chunking (punctuation + pauses + word limits)

  • 🧠 Human-friendly subtitle splitting

  • πŸͺΆ Lightweight & fast (Bun-powered)

  • 🎬 Presets for different content styles:

    • reels (short captions)
    • youtube
    • podcast
  • πŸ—£ Speaker labels support

  • πŸ“„ Multiple formats (.srt, .vtt)

  • πŸ›‘ Robust error handling


πŸ“¦ Installation

npm install subchunk
# or
yarn add subchunk
# or
bun add subchunk

πŸ’» Usage

subchunk is a pure function that processes ElevenLabs JSON directly. It has no file-system dependencies, making it perfect for both Node.js/Bun environments and the browser!

import { convertElevenlabsJsonToSubtitle } from "subchunk";

// 1. Pass the parsed JSON object directly
const elevenLabsData = {
  segments: [
    {
      text: "Hello world",
      words: [
        { text: "Hello", start: 0.1, end: 0.5, type: "word" },
        { text: "world", start: 0.5, end: 1.0, type: "word" }
      ]
    }
  ]
};

const srtOutput = convertElevenlabsJsonToSubtitle(elevenLabsData, {
  format: "srt",
  preset: "reels"
});

console.log(srtOutput);

// 2. Or pass a raw JSON string
const jsonString = JSON.stringify(elevenLabsData);

const vttOutput = convertElevenlabsJsonToSubtitle(jsonString, {
  format: "vtt",
  speaker: true,
  maxWords: 5,
  gap: 0.8
});

πŸ”§ Options

Option Type Default Description
format "srt" | "vtt" "srt" Subtitle format type
maxWords number 8 Max words per subtitle
gap number 0.8 Pause threshold (seconds)
speaker boolean false Include speaker labels
preset "reels" | "youtube" | "podcast" β€” Pre-configured chunking rules

🎯 Presets

Preset Use Case Behavior
reels Shorts / TikTok Very short captions (max 5 words, 0.4s gap)
youtube General videos Balanced (max 8 words, 0.8s gap)
podcast Long conversations Longer subtitles (max 12 words, 1.0s gap)

πŸ“„ Input Format (ElevenLabs JSON)

{
  "segments": [
    {
      "text": "Three minutes.",
      "words": [
        {
          "text": "Three",
          "start": 0.46,
          "end": 0.66,
          "type": "word"
        }
      ]
    }
  ]
}

🧠 How It Works

  1. Extracts words from segments[].words[]
  2. Detects:
    • sentence endings (. ? !)
    • pauses in speech
    • word limits
  3. Groups words into natural subtitle chunks
  4. Formats and returns the .srt or .vtt raw string

🎯 Why This Matters

Good subtitles are critical for:

  • Viewer retention πŸ“ˆ
  • Accessibility β™Ώ
  • Mobile-first content πŸ“±

This tool helps you generate modern, readable captions instead of outdated long blocks.

πŸ“„ License

MIT