Convert SRT to VTT with Python

Convert SRT, VTT, ASS and more in Python with the SubtoVTT API. Full runnable script, error handling, output to file. Free to test. v1 · stable

The fastest path to converting SRT to VTT in a script. The SubtoVTT API is a single multipart/form-data POST — no SDK needed, and requests is the de-facto HTTP client for Python.

Pick Python when you're automating subtitle pipelines, processing batches of files, or running server-side jobs where Python is already installed. For a one-off test, use the free subtitle tester — no signup required.

Prerequisites

pip install requests

Export your API key (accounts start with 100 free credits):

export SUBTOVTT_API_KEY=your_api_key

Convert SRT to VTT

import os
import requests

API_URL = "https://api.example.com/api/v1/convert"
API_KEY = os.environ["SUBTOVTT_API_KEY"]

with open("movie.srt", "rb") as f:
    response = requests.post(
        API_URL,
        headers={"Authorization": f"Bearer {API_KEY}"},
        files={"file": ("movie.srt", f, "application/x-subrip")},
        data={"from": "srt", "to": "vtt"},
    )

if response.status_code != 200:
    raise SystemExit(f"Conversion failed: {response.status_code} {response.text}")

print("Cues:", response.headers.get("X-Cue-Count"))
print("Avg chars/sec:", response.headers.get("X-Avg-Cps"))

with open("movie.vtt", "wb") as out:
    out.write(response.content)

The response body is the converted file, sent as an attachment. The X-Cue-Count and X-Avg-Cps response headers report how many cues were written and the average reading speed of the captions — useful for QA.

Add optional parameters to data={} to adjust timing or formatting in the same request, for example "casing": "title" or "max_line_length": "42".

Tip: the same code converts to any supported target — change "to" to "ass", "txt", or "vtt" as needed.

Convert between any formats

Next

↑ Back to top