n8n-io/n8n · error · NodeOperationError
The provided workflow is not valid JSON: "${(error as Error)
Error message
The provided workflow is not valid JSON: "${(error as Error).message}" What it means
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.
Source
Thrown at packages/@n8n/nodes-langchain/nodes/tools/ToolWorkflow/v2/utils/WorkflowToolService.ts:358
const workflowInfo: IExecuteWorkflowInfo = {};
let subWorkflowId: string;
if (source === 'database') {
const { value } = context.getNodeParameter(
'workflowId',
itemIndex,
{},
) as INodeParameterResourceLocator;
workflowInfo.id = value as string;
subWorkflowId = workflowInfo.id;
} else if (source === 'parameter') {
const workflowJson = context.getNodeParameter('workflowJson', itemIndex) as string;
try {
workflowInfo.code = JSON.parse(workflowJson) as IWorkflowBase;
// subworkflow is same as parent workflow
subWorkflowId = workflowProxy.$workflow.id;
} catch (error) {
throw new NodeOperationError(
context.getNode(),
`The provided workflow is not valid JSON: "${(error as Error).message}"`,
{ itemIndex },
);
}
}
return { workflowInfo, subWorkflowId: subWorkflowId! };
}
private prepareRawData(
context: ISupplyDataFunctions | IExecuteFunctions,
query: string | IDataObject,
itemIndex: number,
): IDataObject {
const rawData: IDataObject = { query };
const workflowFieldsJson = context.getNodeParameter('fields.values', itemIndex, [], {
rawExpressions: true,View on GitHub (pinned to 5ac6606e81)
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.
Example fix
// before: workflowJson contains '{ "nodes": [ {' (broken)
// after: paste the full valid export, or:
source: 'database'
workflowId: { __rl: true, value: '42', mode: 'id' } Defensive patterns
Strategy: validation
Validate before calling
const workflowJson = context.getNodeParameter('workflowJson', itemIndex) as string;
try { JSON.parse(workflowJson); }
catch (e) { throw new Error(`workflowJson invalid: ${e.message}`); } Type guard
function isParsableWorkflowJson(s: string): boolean {
try { JSON.parse(s); return true; } catch { return false; }
} Try / catch
try { workflowInfo.code = JSON.parse(workflowJson); }
catch (error) { /* guide user to fix JSON */ } Prevention
- Download workflow exports from n8n rather than hand-editing.
- Lint pasted JSON before saving.
- Prefer 'Database' source over 'Parameter'.
When it happens
Trigger: Hand-edited or truncated workflow JSON pasted into the node's workflowJson parameter; smart quotes or stray characters introduced during copy-paste.
Common situations: Editing the parameter manually; pasting partial exports; switching a workflow from database-linked to inline and mangling the JSON.
Related errors
- The provided workflow is not valid JSON: "${(error as Error)
- Could not replace placeholders in ${key}: ${error.message}
- Error during parsing of JSON Schema. ${error}
- Failed to read prebuilt-workflows manifest at ${path}: ${msg
- Additional Model Request Fields must be valid JSON
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/73a1fb4f446db73f.
Report an issue: GitHub.