{"record":{"id":"86b79375dd4ba2fd","repo":"remotion-dev/remotion","slug":"unsupported-caption-file-choose-a-json-file","errorCode":null,"errorMessage":"Unsupported caption file. Choose a .json file.","messagePattern":"Unsupported caption file\\. Choose a \\.json file\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/studio/src/components/parse-caption-file.ts","lineNumber":19,"sourceCode":"import type {Caption} from '@remotion/captions';\n\nconst isObject = (value: unknown): value is Record<string, unknown> => {\n\treturn typeof value === 'object' && value !== null && !Array.isArray(value);\n};\n\nconst isFiniteNumber = (value: unknown): value is number => {\n\treturn typeof value === 'number' && Number.isFinite(value);\n};\n\nexport const parseCaptionFile = ({\n\tfileName,\n\tcontents,\n}: {\n\tfileName: string;\n\tcontents: string;\n}): Caption[] => {\n\tif (!fileName.toLowerCase().endsWith('.json')) {\n\t\tthrow new Error('Unsupported caption file. Choose a .json file.');\n\t}\n\n\tlet parsed: unknown;\n\ttry {\n\t\tparsed = JSON.parse(contents);\n\t} catch (error) {\n\t\tthrow new Error(\n\t\t\t`Invalid JSON: ${error instanceof Error ? error.message : String(error)}`,\n\t\t);\n\t}\n\n\tif (!Array.isArray(parsed)) {\n\t\tthrow new Error('Expected a Remotion Caption[] JSON array.');\n\t}\n\n\tlet previousStart: number | null = null;\n\tfor (const [index, caption] of parsed.entries()) {\n\t\tconst path = `captions[${index}]`;","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/remotion-dev/remotion/blob/b2f4e34732f3c6c222ea029413e22dc402218cd7/packages/studio/src/components/parse-caption-file.ts#L1-L37","documentation":"Thrown by parseCaptionFile in Remotion Studio when the selected caption file does not end (case-insensitively) with '.json'. Only JSON caption files in Remotion's Caption[] format can be imported through this path.","triggerScenarios":"Selecting or passing a .srt, .vtt, .txt, or extensionless file to parseCaptionFile.","commonSituations":"Users exporting captions from editors as SRT/VTT and dragging them into Studio, expecting automatic conversion.","solutions":["Convert the file to Remotion's JSON Caption[] format and use the .json extension.","Rename/verify the file extension is .json (content must also be valid JSON).","Use a converter (e.g. from SRT/VTT to Remotion captions) before importing."],"exampleFix":"// before\nparseCaptionFile({ fileName: 'captions.srt', contents })\n// after\nparseCaptionFile({ fileName: 'captions.json', contents: JSON.stringify(captions) })","handlingStrategy":"validation","validationCode":"if (!fileName.toLowerCase().endsWith('.json')) {\n  throw new Error('Convert captions to .json first');\n}","typeGuard":"const isJsonCaptionFile = (name: string): boolean => name.toLowerCase().endsWith('.json');","tryCatchPattern":"try { parseCaptionFile({fileName, contents}); } catch (e) { if (String(e.message).includes('Unsupported caption file')) { /* convert SRT/VTT to JSON */ } else throw e; }","preventionTips":["Export captions as Remotion Caption[] JSON, not SRT/VTT.","Check the extension in file input filters (accept=\".json\").","Convert formats before import."],"tags":["validation","file-format","captions"],"backgroundTag":"incompatible-source-type","analyzedSha":"b2f4e34732f3c6c222ea029413e22dc402218cd7","analyzedAt":"2026-09-09T13:27:51.281Z","contentChangedAt":"2026-09-09T13:27:51.281Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}