catalogue / tools / Audio & video / SRT to WebVTT

Convert SRT to WebVTT

To convert SRT to WebVTT, send one POST to /v1/subtitle-convert with the SRT source and "to": "vtt" in the body. "vtt" is the schema default of "to", so the field may also be left out. 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 SRT to WebVTT run of subtitle-convert.

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

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

{
  "source_url": "https://grist.tools/samples/av/subtitle-captions.srt",
  "source_format": "srt",
  "target_format": "vtt",
  "cue_count": 3,
  "subtitle": "WEBVTT\n\n00:00:01.000 --> 00:00:03.500\nThe tide goes out slowly.\n\n00:00:04.000 --> 00:00:06.250\nShells line the wet sand,\none row after another.\n\n00:00:07.000 --> 00:00:09.000\nBy noon the water returns.\n"
}

Source file: av/subtitle-captions.srt, 200 bytes. SubRip subtitle file with three cues of neutral sample text, one of them spanning two lines. The recorded run returned 202 bytes of WebVTT, 1 times the source size, with 3 cues.

The returned text starts with the line WEBVTT. Its 3 timing lines are 00:00:01.000 --> 00:00:03.500, 00:00:04.000 --> 00:00:06.250 and 00:00:07.000 --> 00:00:09.000, giving hours, minutes and seconds, and a full stop before the milliseconds. No cue has an identifier line above its timing.

03Format notes

SRT as a source

SubRip has no identifying byte signature. subtitle-convert decides the source format from content: a file that does not start with WEBVTT is parsed as SubRip and must yield at least one cue, otherwise it is refused as an unrecognised type. The parser is pure JavaScript and never invokes ffmpeg. Blocks are split on blank lines, a leading byte order mark and CRLF line endings are tolerated, and the timing line may be the first or second line of a block, so the numeric index is optional. Timestamps use HH:MM:SS,mmm, and a dot is accepted as the decimal separator so a mislabelled file still parses; minutes or seconds above fifty-nine are not accepted as a timestamp. Caption text after the timing line keeps its line breaks, and cues are converted in their original order.

WebVTT as a target

subtitle-convert writes WebVTT as the WEBVTT header, a blank line, then cues with dotted timestamps in HH:MM:SS.mmm form. WebVTT is that service's default destination. Output is rebuilt from each cue's start, end and text, so SubRip index numbers disappear and no positioning settings are added. Text subtitle tracks inside media containers take a different writer: subtitle-extract passes them through ffmpeg's webvtt muxer, and in the recorded extraction results that muxer prints timestamps without an hour component. Metadata is stripped and bit-exact flags are set on that route, so the same stream yields the same text for a pinned ffmpeg. Both routes end in the same format, while the serialiser, and therefore the exact timestamp layout, depends on whether the captions started as a file or as a track. Nothing follows the end timestamp on a timing line, because subtitle-convert writes no cue settings, and no identifier precedes a cue.

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 SRT to WebVTT?
$0.003 per call, paid in USDC on Base via x402.
How large can the SRT 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