Convert SRT to VTT in the browser

Convert subtitle formats from the browser with fetch and the SubtoVTT API. No server needed — send a POST, download the result. v1 · stable

Convert SRT to VTT entirely in the browser with the native fetch and FormData APIs — no build step, no server code, no page reload. This is the same flow that powers the free subtitle tester on the homepage.

Use the browser flow for quick experiments, internal tools, or a client-side conversion UI. For production, keep the API key on the server and call the API from there.

Convert SRT to VTT

async function convertSrtToVtt(file, apiKey) {
    const form = new FormData();
    form.append("file", file, "movie.srt");
    form.append("from", "srt");
    form.append("to", "vtt");

    const response = await fetch("https://api.example.com/api/v1/convert", {
        method: "POST",
        headers: { Authorization: `Bearer ${apiKey}` },
        body: form,
    });

    if (!response.ok) {
        throw new Error(`Conversion failed: ${response.status}`);
    }

    const blob = await response.blob();
    const url = URL.createObjectURL(blob);
    const link = document.createElement("a");
    link.href = url;
    link.download = "movie.vtt";
    link.click();
    URL.revokeObjectURL(url);
}

Pass the <input type="file"> element's .files[0] as fileFormData sends it as the file multipart field automatically. The response is a Blob; the snippet triggers a download of movie.vtt.

Warning: a browser has no place to hide a secret. If you embed an API key here, anyone can read it from the page source. The free tester on the homepage needs no key at all — accounts start with 100 free credits. Use this example for internal tools or server-proxied requests.

Convert between any formats

Next

↑ Back to top