catalogue / tools / Audio & video / WebVTT to SRT

Convert WebVTT to SRT

To convert WebVTT to SRT, send one POST to /v1/subtitle-convert with the WebVTT source and "to": "srt" in the body. Left out, "to" falls back to its default "vtt", so a SRT request has to send it. Each call costs $0.003 in USDC on Base via x402, with no account and no API key. The source file can be up to 5 MB.

Endpoint
POST /v1/subtitle-convert
Price
$0.003 per call

01Limits

LimitValue
Largest source file5 MB (5,242,880 bytes)
Timeout15 s
Source formatsSRT, WebVTT
Output formatsWebVTT, SRT

02Example

A real WebVTT to SRT run of subtitle-convert.

Request
POST /v1/subtitle-convert
content-type: application/json
payment-signature: <base64 x402 payload>

{
  "url": "https://grist.tools/samples/av/pair-captions.vtt",
  "to": "srt"
}
Response
200 OK
payment-response: <base64 settlement receipt>

{
  "source_url": "https://grist.tools/samples/av/pair-captions.vtt",
  "source_format": "vtt",
  "target_format": "srt",
  "cue_count": 2,
  "subtitle": "1\n00:00:00,000 --> 00:00:01,750\nRain taps on the window.\n\n2\n00:00:02,250 --> 00:00:03,750\nA lamp glows in the hall.\n"
}

Source file: av/pair-captions.vtt, 120 bytes. WebVTT file with two short captions over the first 4 seconds, written by hand; the same two cues are muxed into the pair-clip videos. The recorded run returned 116 bytes of SRT, 97% of the source size, with 2 cues.

The returned text starts with cue number 1. Its 2 timing lines are 00:00:00,000 --> 00:00:01,750 and 00:00:02,250 --> 00:00:03,750, giving hours, minutes and seconds, and a comma before the milliseconds. Every cue has a number line above its timing, 1 and 2.

03Format notes

WebVTT as a source

A WebVTT file must begin with the signature WEBVTT, optionally preceded by a byte order mark and followed by whitespace or the end of the file. subtitle-convert uses that signature to tell the format apart from SubRip. Timestamps may omit the hour, so both MM:SS.mmm and HH:MM:SS.mmm parse. The reader skips the header and any NOTE, STYLE or REGION block, and it discards positioning settings that follow a cue's timestamps. A cue identifier line above the timing is not kept either, because each cue is reduced to its start time, end time and text before being written in the other format. Styling therefore does not reach the output, while caption text and its line breaks do. A document with no parseable cue is refused before anything is serialised.

SRT as a target

SRT written by subtitle-convert numbers its cues sequentially from one and prints every timestamp as HH:MM:SS,mmm with a comma before the milliseconds, hours always included. When the source is WebVTT, each cue is rebuilt from its start, end and text, so cue identifiers, positioning settings and NOTE blocks do not survive. SubRip is also the default destination of subtitle-extract, which pulls a text subtitle stream out of a media container and writes it with ffmpeg's srt muxer instead of the JavaScript serialiser. That route refuses a stream that produces no text rather than returning an empty file, and it reports a cue count obtained by counting the timing arrows in the output. The two routes share the destination format but not the code that writes it. In the subtitle-convert file, each block stacks its index line, its timing line and its caption text, consecutive blocks are parted by one empty line, and one line feed closes the file.

04Errors

CodeHTTP
invalid_input400
blocked_target403
unreachable_target424
upstream_timeout424
unsupported_content_type415
too_large413
unprocessable422
internal500

When each is raised, and what it means for payment: /docs/subtitle-convert.

05Questions

What does it cost to convert WebVTT to SRT?
$0.003 per call, paid in USDC on Base via x402.
How large can the WebVTT file be?
Up to 5 MB (5,242,880 bytes). Past a limit the call answers too_large (413).
What happens if the conversion fails?
The tool answers with a typed JSON error from the errors table. Payment is settled only after the tool has produced its result; a call that fails inside the tool is never settled.

06Related