JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 15
  • Score
    100M100P100Q72304F
  • 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

Run instantly

bunx subchunk input.json -o output.srt

Install globally

bun install -g subchunk

πŸš€ Usage

subchunk <input.json> [options]

πŸ”§ Options

Flag Description Default
-o, --output Output file output.srt
--format srt or vtt srt
--maxWords Max words per subtitle 8
--gap Pause threshold (seconds) 0.8
--speaker Include speaker labels false
--preset reels, youtube, podcast β€”

πŸ’» Programmatic Usage

You can also import subchunk as a library in your Node.js or Bun projects. It includes first-class TypeScript support.

import { convertElevenlabsJsonToSubtitle } from "subchunk";

// 1. Pass a file path and get the string result
const srtOutput = await convertElevenlabsJsonToSubtitle("input.json", {
  format: "srt",
  preset: "reels"
});

// 2. Or pass the JSON object directly
const vttOutput = await convertElevenlabsJsonToSubtitle(myJsonObject, {
  format: "vtt",
  speaker: true
});

// 3. Write directly to a file by specifying 'output'
await convertElevenlabsJsonToSubtitle("input.json", {
  output: "output.srt",
  maxWords: 5,
  gap: 0.5
});

🎯 Presets

Preset Use Case Behavior
reels Shorts / TikTok Very short captions
youtube General videos Balanced
podcast Long conversations Longer subtitles

Example:

subchunk input.json --preset reels

πŸ“„ 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 into .srt or .vtt


πŸ§ͺ Examples

# basic
subchunk input.json

# reels (short captions)
subchunk input.json --preset reels

# include speaker labels
subchunk input.json --speaker

# VTT format
subchunk input.json --format vtt

# custom tuning
subchunk input.json --maxWords 6 --gap 0.5

🎯 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