Convert SRT to VTT with Rust using the reqwest blocking client and its built-in multipart support. It's one small dependency that removes all the boundary and header plumbing.
Pick Rust when you need a single static binary, a minimal memory footprint, or maximum throughput in a subtitle-processing pipeline.
Add the dependency
[dependencies]
reqwest = { version = "0.12", features = ["multipart", "blocking"] }
Convert SRT to VTT
use std::fs;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let api_key = std::env::var("SUBTOVTT_API_KEY")?;
let client = reqwest::blocking::Client::new();
let file = fs::read("movie.srt")?;
let part = reqwest::blocking::multipart::Part::bytes(file)
.file_name("movie.srt")
.mime_str("application/x-subrip")?;
let form = reqwest::blocking::multipart::Form::new()
.part("file", part)
.text("from", "srt")
.text("to", "vtt");
let response = client
.post("https://api.example.com/api/v1/convert")
.bearer_auth(&api_key)
.multipart(form)
.send()?;
if !response.status().is_success() {
eprintln!("Conversion failed: {} {}", response.status(), response.text()?);
std::process::exit(1);
}
if let Some(cues) = response.headers().get("x-cue-count") {
println!("Cues: {}", cues.to_str()?);
}
fs::write("movie.vtt", response.bytes()?)?;
Ok(())
}
reqwest handles the multipart framing, and bearer_auth sets the Authorization: Bearer <key> header for you. The converted file arrives as the response body and is written to movie.vtt.
The x-cue-count response header tells you how many cues the converter wrote. Set SUBTOVTT_API_KEY in your environment first (100 free credits on key creation).
Tip: build with
cargo build --releasefor a static binary you can drop onto any server — no runtime required.
Convert between any formats
- Convert SRT to VTT →
- Convert VTT to SRT →
- Convert ASS to SRT →
- Convert SRT to ASS →
- Convert ASS to VTT →
- Convert VTT to ASS →
- Convert SRT to TXT →
Next
- Convert SRT to VTT in the browser →
- Convert SRT to VTT with Python →
- Full API reference →
- Free subtitle tester → — no signup required