YouTube Transcript Cleaner & Extractor - n8n Workflow

Use this powerful n8n workflow to automatically extract, clean, and format transcripts from your YouTube videos using the Data API. Ideal for content repurposing and AI processing. Easily import this n8n template.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Content creators who need clean, structured transcripts for repurposing.
Data analysts performing sentiment analysis or keyword extraction on video content.
Users seeking robust n8n templates for integrating video data into AI pipelines.
Developers building custom tools that require high-quality video captions.

Overview

Raw captions downloaded directly from the YouTube API (VTT format) are often cluttered with timestamps, headers, and noise (like [Música]). This makes them unusable for direct AI processing or article generation. This specialized n8n workflow solves this by providing a complete, automated cleaning pipeline.

This n8n template uses the YouTube Data API to locate and download captions, prioritizing a specified language. The core value of this n8n workflow lies in the custom Code nodes, which expertly strip out metadata, resulting in a plain, readable text transcript ready for downstream applications. This n8n solution is crucial for anyone needing clean data from their video library, making it one of the most practical n8n templates for content automation.

Important Limitation: Due to YouTube API restrictions, this n8n workflow can only successfully extract captions from videos belonging to the authenticated YouTube channel.

How it Works

This n8n workflow operates as a highly efficient sub-process, triggered externally to handle transcript requests.


  1. Input Trigger: The process begins with the When Executed by Another Workflow n8n trigger, receiving the youtubeVideoId and an optional preferredLanguage (e.g., 'es'). These variables are immediately stored by the Set Variables n8n node.

  2. API Query: The List Captions n8n node (HTTP Request) queries the YouTube Data API to retrieve a list of all available caption tracks for the given video ID.

  3. Conditional Split: The IF Has Captions? n8n node checks if any captions exist (items.length > 0).

  4. Success Path (Captions Found):

The Caption Language Selector n8n node (Code) implements custom logic. It searches for a caption matching the preferredLanguage. If not found, it defaults to the first available caption ID.
The Download VTT n8n node uses the selected caption ID to download the VTT file content (VTT stands for Web Video Text Tracks).
The Caption File Conversion n8n node extracts the VTT data into a text buffer.
The crucial Clean Transcript n8n node (Code) sanitizes the VTT text. It iterates through the content, filtering out VTT headers, timestamps (like 00:01:23.456,00:01:25.789), and bracketed sound effects (like [Música]), finally consolidating the resulting text into a clean, single-string transcript along with useful metadata (word/char count).

  1. Failure Path (No Captions): If no captions are available, the No Captions Fallback n8n node generates a structured error response, and the Stop and Error n8n node terminates the workflow gracefully, preventing downstream failures.

Installation Guide

To deploy this powerful n8n template, follow these steps:


  1. Import Workflow: Copy the provided JSON data and import it into your n8n instance via the 'New' button -> 'Import from JSON'.

  2. YouTube API Credentials: You will need valid YouTube OAuth2 credentials configured in n8n.

  3. Update Credentials: Open the List Captions and Download VTT n8n nodes. In the 'Authentication' section, update the 'Credential' field to use your personal YouTube OAuth2 account.

Required Scope:* Ensure your YouTube credentials include the youtube.captions.read scope.

  1. Testing: Since this uses an Execute Workflow Trigger, you must run it from another parent n8n workflow or use the 'Test Workflow' feature with a JSON payload, such as: {"youtubeVideoId": "YOURVIDEOID", "preferredLanguage": "en"}. Remember, the video ID must belong to your authenticated channel.

Node Details

When Executed by Another Workflow (n8n Trigger): Serves as the starting n8n trigger point for this reusable module. It accepts the youtubeVideoId and preferredLanguage parameters.
List Captions (HTTP Request n8n node): Performs the initial call to the YouTube Data API (captions?part=snippet). It uses your YouTube OAuth2 credentials to list all available caption tracks for the video.
IF Has Captions? (n8n node): A core flow control mechanism. It checks the API response length to determine if the video has captions, directing the n8n workflow down the appropriate path.
Caption Language Selector (Code n8n node): This crucial custom scripting n8n node contains JavaScript logic to prioritize the requested language. It stores the determined captionId for the download step.
Download VTT (HTTP Request n8n node): Downloads the raw VTT file content using the selected captionId. This file contains all the timestamps and metadata.
Caption File Conversion (Extract From File n8n node): Converts the binary VTT file data received from the previous HTTP request into usable raw text content, preparing it for cleaning.


  • Clean Transcript (Code n8n node): The final processing step. This highly customized n8n node uses regex and filtering to systematically remove all VTT specific clutter (timestamps, headers, sound effects) and normalize whitespace, providing the clean, ready-to-use output transcript.

Related n8n Workflows

Free

Nodes: 8 Nodes
Updated: December 26 2025
View all
Created by

Featured*