← Blog  ·  Transcript Cleaner app →

How to Remove Duplicate Lines from Subtitles (and YouTube Transcripts)

If you've ever copied a YouTube transcript, exported a Whisper run, or converted an SRT file and found the same line repeated three times in a row, you're not doing anything wrong. Duplicate caption lines are the single most common form of transcript junk — and most guides skip right past them.

This article covers why the duplicates exist, what breaks when you try to remove them naively, and three working methods: a one-click browser tool, text-editor tricks, and a six-line Python script.

Why duplicate lines happen in the first place

Duplicate subtitle lines aren't random. They come from three specific sources:

1. YouTube's rolling caption window. YouTube renders captions in a small window that scrolls as the speaker talks. When you open "Show transcript" and copy mid-playback — or copy from a panel that re-renders as the video advances — the same line gets captured multiple times as it moves through the window. That's why a raw copy often looks like this:

so I was
so I was
so I was walking

The second and third "so I was" aren't new content — they're the same caption caught at different scroll positions.

2. Whisper and speech-to-text hallucinations. Whisper is excellent, but at long silences, music breaks, or low-confidence audio it can repeat a phrase ("thank you" loops, repeated short lines) before moving on. These repeats look exactly like caption duplicates, and they survive straight into the text.

3. SRT/VTT conversion artifacts. When subtitle files get converted, re-encoded, or stitched together from multiple sources, boundary lines often get duplicated — the last cue of one segment reappears as the first cue of the next.

The fix in every case is subtitle deduplication: collapsing repeated lines back into one. But dedupe is trickier than it sounds.

The naive dedupe pitfalls (read this before removing anything)

Three mistakes account for almost every "my transcript got worse" complaint:

The safe rule: compare consecutive lines only, after normalizing whitespace and case, and keep both lines whenever they differ.

Method 1: One-click with a browser-based cleaner

The fastest approach is to let a transcript cleaner handle dedupe along with everything else. Transcript Cleaner does exactly the rule above: it collapses consecutive duplicate lines, ignoring case and whitespace differences, so the three-line "so I was / so I was / so I was walking" example collapses to "so I was walking" — while a genuinely repeated sentence later in the transcript survives untouched.

It also strips the usual companions of duplicate lines in the same pass: timestamps (0:04, 00:01:23,456 --> …), filler words (um, uh, you know), and tags like [Music] or [Applause]. Paste in a YouTube copy, an SRT, or raw speech text; it auto-detects the format, optionally merges into paragraphs, shows word counts, and lets you copy or download the result as .txt.

And because it runs 100% client-side, nothing is uploaded — which matters if the transcript contains an unpublished interview or client audio.

🔒 The privacy angle matters here: Transcript Cleaner runs 100% in your browser. There is no server component, nothing is uploaded, and it keeps working offline once the page loads. If you're handling unpublished interviews, client recordings, or anything under NDA, that's the difference between "safe to paste" and "don't".

→ Try it free — no signup  ·  → Or jump straight to the dedicated subtitle dedupe tool

Method 2: Text-editor tricks (with one big warning)

If you'd rather not paste into any website, your editor can do dedupe too — with care.

The warning: avoid "sort, then remove duplicates." It reorders your transcript and silently deletes legitimate repeats. Use it only on throwaway copies, never on the text you'll publish.

VS Code: with the built-in regex replace, you can collapse exact consecutive repeats with Find: ^(.*\S)\s*\n\1(\s*\n\1)*$ replaced by $1 — but test it on a copy first; regex across newlines is fiddly, and it won't catch case or whitespace variants.

Notepad++: the cleanest trick is the View → "Show Symbol" plus manual scan for short files, or the free "remove duplicate consecutive lines" style of macro. Honestly, for anything over a page, Method 1 or 3 is less error-prone.

The honest summary: editors are fine for a dozen lines. For real transcripts, they're slower and easier to get wrong than the two options below.

Method 3: A six-line Python script

If you already work in a terminal or notebook, this is the whole dedupe — keep a line only when its normalized form differs from the previous kept line:

def dedupe(lines):
    kept, last = [], None
    for line in lines:
        norm = " ".join(line.split()).lower()  # normalize whitespace + case
        if norm and norm != last:
            kept.append(line.rstrip())
            last = norm
    return kept

with open("raw.txt", encoding="utf-8") as f:
    text = dedupe(f.readlines())
with open("clean.txt", "w", encoding="utf-8") as f:
    f.writelines(text)

Eight lines, no dependencies, and it handles the three pitfalls: normalization (whitespace + case), consecutive-only comparison, and prefix-overlap safety ("so I was" ≠ "so I was walking"). Blank lines are dropped; if you need them, keep them in a separate pass. This works equally well for a copied YouTube transcript and for the text portion of an SRT after you've stripped the timestamp lines.

When duplicate lines are actually legitimate

Dedupe is a cleanup tool, not a truth engine. Some repeats are real:

The honest caveat: review before publishing. A dedupe pass is mechanical — it can't tell an artifact from emphasis. Skim the output, especially around choruses, slogans, and emotional moments, and undo anything that looks like real speech.

FAQ

Does Whisper really repeat lines?
Yes, occasionally. Whisper can repeat short phrases during long silences, music, or unclear audio — the classic "thank you." loop. It's rare but real, and consecutive-duplicate dedupe removes it without touching the rest of the text.

Why does my YouTube copy have the same line twice?
Because you copied mid-playback. The caption window re-renders as the video advances, so the same caption line gets captured at two scroll positions. It's a copying artifact, not extra content — safe to collapse.

Will dedupe remove real repeated content?
Only exact consecutive repeats. A sentence repeated later in the transcript (non-adjacent) is kept, and "so I was" followed by "so I was walking" is kept because those are different lines. What gets removed is precisely the rolling-caption and Whisper-repeat pattern.

Is it safe to run my transcript through an online dedupe tool?
Only if processing happens in your browser. If a site uploads your text, assume it could be stored or logged. A client-side cleaner does the work locally and nothing leaves your machine — the question to ask before pasting anything unpublished.