{"record":{"id":"73a1fb4f446db73f","repo":"n8n-io/n8n","slug":"the-provided-workflow-is-not-valid-json-error-73a1fb","errorCode":null,"errorMessage":"The provided workflow is not valid JSON: \"${(error as Error).message}\"","messagePattern":"The provided workflow is not valid JSON: \"(.+?)\"","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/tools/ToolWorkflow/v2/utils/WorkflowToolService.ts","lineNumber":358,"sourceCode":"\t\tconst workflowInfo: IExecuteWorkflowInfo = {};\n\t\tlet subWorkflowId: string;\n\n\t\tif (source === 'database') {\n\t\t\tconst { value } = context.getNodeParameter(\n\t\t\t\t'workflowId',\n\t\t\t\titemIndex,\n\t\t\t\t{},\n\t\t\t) as INodeParameterResourceLocator;\n\t\t\tworkflowInfo.id = value as string;\n\t\t\tsubWorkflowId = workflowInfo.id;\n\t\t} else if (source === 'parameter') {\n\t\t\tconst workflowJson = context.getNodeParameter('workflowJson', itemIndex) as string;\n\t\t\ttry {\n\t\t\t\tworkflowInfo.code = JSON.parse(workflowJson) as IWorkflowBase;\n\t\t\t\t// subworkflow is same as parent workflow\n\t\t\t\tsubWorkflowId = workflowProxy.$workflow.id;\n\t\t\t} catch (error) {\n\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\tcontext.getNode(),\n\t\t\t\t\t`The provided workflow is not valid JSON: \"${(error as Error).message}\"`,\n\t\t\t\t\t{ itemIndex },\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn { workflowInfo, subWorkflowId: subWorkflowId! };\n\t}\n\n\tprivate prepareRawData(\n\t\tcontext: ISupplyDataFunctions | IExecuteFunctions,\n\t\tquery: string | IDataObject,\n\t\titemIndex: number,\n\t): IDataObject {\n\t\tconst rawData: IDataObject = { query };\n\t\tconst workflowFieldsJson = context.getNodeParameter('fields.values', itemIndex, [], {\n\t\t\trawExpressions: true,","sourceCodeStart":340,"sourceCodeEnd":376,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/tools/ToolWorkflow/v2/utils/WorkflowToolService.ts#L340-L376","documentation":"Thrown by WorkflowToolService.getSubWorkflowInfo (v2) when 'Source' is 'Parameter' and JSON.parse of the workflowJson parameter fails. Identical cause to the v1 equivalent (error 750): an inline workflow definition that isn't valid JSON.","triggerScenarios":"Hand-edited or truncated workflow JSON pasted into the node's workflowJson parameter; smart quotes or stray characters introduced during copy-paste.","commonSituations":"Editing the parameter manually; pasting partial exports; switching a workflow from database-linked to inline and mangling the JSON.","solutions":["Re-download the workflow JSON from n8n and paste it unedited.","Validate the JSON in a linter and fix the reported error.","Switch 'Source' to 'Database' and select the workflow by ID to avoid inline JSON entirely."],"exampleFix":"// before: workflowJson contains '{ \"nodes\": [ {' (broken)\n// after: paste the full valid export, or:\nsource: 'database'\nworkflowId: { __rl: true, value: '42', mode: 'id' }","handlingStrategy":"validation","validationCode":"const workflowJson = context.getNodeParameter('workflowJson', itemIndex) as string;\ntry { JSON.parse(workflowJson); }\ncatch (e) { throw new Error(`workflowJson invalid: ${e.message}`); }","typeGuard":"function isParsableWorkflowJson(s: string): boolean {\n  try { JSON.parse(s); return true; } catch { return false; }\n}","tryCatchPattern":"try { workflowInfo.code = JSON.parse(workflowJson); }\ncatch (error) { /* guide user to fix JSON */ }","preventionTips":["Download workflow exports from n8n rather than hand-editing.","Lint pasted JSON before saving.","Prefer 'Database' source over 'Parameter'."],"tags":["workflow-tool","json","configuration","ai-tool"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}