n8n_export_workflow
Export n8n workflows as JSON files for backup purposes or to transfer them between different n8n instances.
Instructions
Export a workflow as JSON for backup or import elsewhere.
Args:
id (string): Workflow ID to export
Returns: Complete workflow JSON that can be imported into another n8n instance.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Workflow ID to export |
Implementation Reference
- src/tools/audit-utils.ts:183-221 (handler)The implementation of the `n8n_export_workflow` tool, which retrieves a workflow by ID, sanitizes it by removing instance-specific fields, and returns the JSON.
server.registerTool( 'n8n_export_workflow', { title: 'Export Workflow JSON', description: `Export a workflow as JSON for backup or import elsewhere. Args: - id (string): Workflow ID to export Returns: Complete workflow JSON that can be imported into another n8n instance.`, inputSchema: z.object({ id: z.string().min(1).describe('Workflow ID to export') }).strict(), annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false } }, async (params: { id: string }) => { const workflow = await get<Record<string, unknown>>(`/workflows/${params.id}`); // Remove instance-specific fields for export const exportable = { ...workflow }; delete exportable.id; delete exportable.createdAt; delete exportable.updatedAt; delete exportable.versionId; const json = JSON.stringify(exportable, null, 2); return { content: [{ type: 'text', text: `**Exported Workflow: ${(workflow as { name?: string }).name || params.id}**\n\n\`\`\`json\n${json}\n\`\`\`` }], structuredContent: exportable }; } );