AutomationFlowsGeneral › Transfer Workflows with Credentials & Sub-workflow Management Between N8n…

Transfer Workflows with Credentials & Sub-workflow Management Between N8n…

Original n8n title: Transfer Workflows with Credentials & Sub-workflow Management Between N8n Instances

ByArthur Braghetto @arthurmb on n8n.io

This workflow contains community nodes that are only compatible with the self-hosted version of n8n.

Event trigger★★★★★ complexity54 nodesForm Triggern8nFormExecute CommandRead Write File
General Trigger: Event Nodes: 54 Complexity: ★★★★★ Added:

This workflow corresponds to n8n.io template #8620 — we link there as the canonical source.

This workflow follows the Executecommand → Readwritefile recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "h6pksN4Txbngklog",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "WorkflowExporter",
  "tags": [],
  "nodes": [
    {
      "id": "5270c0cb-3c3f-4430-9504-b59282e2a4c4",
      "name": "Workflow Exporter",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -864,
        -688
      ],
      "parameters": {
        "options": {
          "ignoreBots": true,
          "buttonLabel": "Start",
          "appendAttribution": false,
          "useWorkflowTimezone": true
        },
        "formTitle": "Workflow Exporter",
        "formDescription": "Click Start to choose the workflow you want to export."
      },
      "typeVersion": 2.3
    },
    {
      "id": "6f799511-6915-4d04-8729-2df27cb7578f",
      "name": "Get all workflows",
      "type": "n8n-nodes-base.n8n",
      "position": [
        -640,
        -688
      ],
      "parameters": {
        "filters": {
          "excludePinnedData": true
        },
        "requestOptions": {}
      },
      "credentials": {
        "n8nApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "024c0dcb-b3ff-49ab-851f-9c5690c80f9e",
      "name": "Build Dropdown",
      "type": "n8n-nodes-base.code",
      "position": [
        -192,
        -688
      ],
      "parameters": {
        "jsCode": "let values = [];\nfor (const item of $input.all()) {\n  values.push(\n    {\"option\": item.json.name}\n  );\n}\n\nreturn {\n  json: {\n    \"values\": values\n  }\n};"
      },
      "executeOnce": false,
      "typeVersion": 2
    },
    {
      "id": "fdd58b21-5643-46a8-ab71-92a7bad9bb69",
      "name": "Workflow Selector",
      "type": "n8n-nodes-base.form",
      "position": [
        32,
        -688
      ],
      "parameters": {
        "options": {
          "buttonLabel": "Next"
        },
        "defineForm": "json",
        "jsonOutput": "=[\n  {\n    \"fieldLabel\": \"Workflow to export\",\n    \"fieldType\": \"dropdown\",\n    \"fieldOptions\": {\n      \"values\": {{ $json.values.toJsonString() }}\n    },\n    \"requiredField\": true\n  }\n]"
      },
      "typeVersion": 2.3
    },
    {
      "id": "0b47ce24-b125-4227-be11-acaaa2de8fe5",
      "name": "Workflow to Export",
      "type": "n8n-nodes-base.n8n",
      "position": [
        928,
        -592
      ],
      "parameters": {
        "filters": {
          "name": "={{ $('Workflow Selector').item.json['Workflow to export'] }}",
          "excludePinnedData": true
        },
        "requestOptions": {}
      },
      "credentials": {
        "n8nApi": {
          "name": "<your credential>"
        }
      },
      "executeOnce": true,
      "typeVersion": 1
    },
    {
      "id": "b74af0f1-4a0f-4b17-b342-c675f1f2ef33",
      "name": "Credentials List",
      "type": "n8n-nodes-base.code",
      "position": [
        4064,
        -592
      ],
      "parameters": {
        "jsCode": "let credentials = [];\nconst wf = $input.first().json;\nconst seen = new Set();\n\nfor (const node of wf.nodes) {\n  const credsObj = node.credentials || {};\n\n  for (const [credentialType, cval] of Object.entries(credsObj)) {\n    if (!cval || (typeof cval !== 'object')) continue;\n    const credentialId = cval.id ?? null;\n    const credentialName = cval.name ?? null;\n    if (!seen.has(credentialId)) {\n      seen.add(credentialId);\n      credentials.push({\n        credentialType,\n        credentialName,\n        credentialId\n      });\n    }\n  }\n  \n}\n\nreturn credentials;"
      },
      "typeVersion": 2,
      "alwaysOutputData": true
    },
    {
      "id": "378af341-221c-49e8-a2b3-478d708481ba",
      "name": "Credentials to File",
      "type": "n8n-nodes-base.executeCommand",
      "onError": "continueRegularOutput",
      "position": [
        5184,
        -480
      ],
      "parameters": {
        "command": "=n8n export:credentials --id={{ $json.credentialId }} --decrypted --output=/home/node/{{ $json.credentialId }}.json",
        "executeOnce": false
      },
      "typeVersion": 1,
      "alwaysOutputData": false
    },
    {
      "id": "14255653-9bc3-485f-a472-2ed2636e76ba",
      "name": "Read Credentials Files",
      "type": "n8n-nodes-base.readWriteFile",
      "position": [
        5408,
        -480
      ],
      "parameters": {
        "options": {},
        "fileSelector": "=/home/node/*.json"
      },
      "executeOnce": true,
      "typeVersion": 1
    },
    {
      "id": "6fb8b7d6-fd0a-49c4-a18f-34ffe61626b4",
      "name": "Credentials Files to Json",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        5632,
        -480
      ],
      "parameters": {
        "options": {},
        "operation": "fromJson",
        "destinationKey": "cred"
      },
      "typeVersion": 1
    },
    {
      "id": "e44310c1-4c91-4331-bf8a-35882c67ca76",
      "name": "Credentials to Export",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        5856,
        -480
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "cred"
      },
      "typeVersion": 1
    },
    {
      "id": "362b95c3-ccb6-4687-b8c3-77db03606fdb",
      "name": "Delete Credentials Files",
      "type": "n8n-nodes-base.executeCommand",
      "position": [
        6080,
        -576
      ],
      "parameters": {
        "command": "rm -rf /home/node/*.json"
      },
      "executeOnce": true,
      "typeVersion": 1
    },
    {
      "id": "142d1517-da3a-4cb9-b38c-93f0692cf2e6",
      "name": "Export Credentials",
      "type": "n8n-nodes-base.n8n",
      "onError": "continueErrorOutput",
      "position": [
        6080,
        -384
      ],
      "parameters": {
        "data": "={{ $json.data.toJsonString() }}",
        "name": "={{ $json.name }}",
        "resource": "credential",
        "requestOptions": {},
        "credentialTypeName": "={{ $json.type }}"
      },
      "credentials": {
        "n8nApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "6e19cfee-5001-4b74-8b75-0438083e4ebe",
      "name": "Fix Workflow Creds Ids",
      "type": "n8n-nodes-base.code",
      "position": [
        6304,
        -384
      ],
      "parameters": {
        "jsCode": "let wf = JSON.stringify($('Workflow to Export Ready').first());\n\nfor (const item of $input.all()) {\n\n  for (const oldcred of $('Credentials to Export').all()) {\n    if (oldcred.json.name === item.json.name) {\n      wf = wf.replaceAll(oldcred.json.id, item.json.id);\n    }\n  }\n\n}\n\nreturn JSON.parse(wf);"
      },
      "typeVersion": 2
    },
    {
      "id": "5dd4141b-6c5d-4dbf-adb7-3db284f47d56",
      "name": "Already Exists",
      "type": "n8n-nodes-base.if",
      "position": [
        704,
        -688
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "67e4ee16-1f6b-4f4c-bd9b-1e221da92487",
              "operator": {
                "type": "object",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "43af2a3e-e51a-4f7c-ad4a-895ddeff10ce",
      "name": "Workflow Name Clash",
      "type": "n8n-nodes-base.form",
      "position": [
        928,
        -784
      ],
      "parameters": {
        "options": {},
        "operation": "completion",
        "completionTitle": "Error",
        "completionMessage": "=A workflow with the same name ({{ $json.name }}) already exists at target system."
      },
      "typeVersion": 2.3
    },
    {
      "id": "4f88274b-f358-4726-90e7-adde105939a6",
      "name": "Filter Archived 1",
      "type": "n8n-nodes-base.filter",
      "position": [
        -416,
        -688
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "200d8890-458b-4a59-b12e-b9ec8e3c9d1e",
              "operator": {
                "type": "boolean",
                "operation": "false",
                "singleValue": true
              },
              "leftValue": "={{ $json.isArchived }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "ee99bb42-96c8-47f5-a3b9-80b48748dbab",
      "name": "No Credentials",
      "type": "n8n-nodes-base.if",
      "position": [
        4288,
        -592
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "67e4ee16-1f6b-4f4c-bd9b-1e221da92487",
              "operator": {
                "type": "object",
                "operation": "empty",
                "singleValue": true
              },
              "leftValue": "={{ $json }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "483a6568-4a8f-46b8-b254-dda558f959b8",
      "name": "Confirm Creds Export",
      "type": "n8n-nodes-base.form",
      "position": [
        4512,
        -528
      ],
      "parameters": {
        "options": {
          "formTitle": "Workflow Credentials",
          "buttonLabel": "Next",
          "formDescription": "=This workflow contains credentials. It is not possible to verify whether the same credentials already exist in the target system, so duplicates may occur.\n<br><br>\nCredentials Found:<br>\n{{ $('Credentials List').all().map(c => c.json.credentialName).join(', ') }}"
        },
        "formFields": {
          "values": [
            {
              "fieldType": "radio",
              "fieldLabel": "Export Credentials?",
              "fieldOptions": {
                "values": [
                  {
                    "option": "Yes"
                  },
                  {
                    "option": "No"
                  }
                ]
              },
              "requiredField": true
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "27e11eaa-b761-42a2-8742-c5d5a9d5c430",
      "name": "Skip Credentials",
      "type": "n8n-nodes-base.if",
      "position": [
        4736,
        -528
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "d85a6267-fa07-4bec-9393-cc4edb1de1d6",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json['Export Credentials?'] }}",
              "rightValue": "No"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "2bcb08ab-4a91-4cae-b625-104d612f2517",
      "name": "Return Credentials List",
      "type": "n8n-nodes-base.code",
      "position": [
        4960,
        -480
      ],
      "parameters": {
        "jsCode": "return $('Credentials List').all();"
      },
      "typeVersion": 2
    },
    {
      "id": "0aeb1327-ba7d-498b-a215-eec17f772c89",
      "name": "Exported no creds",
      "type": "n8n-nodes-base.form",
      "position": [
        5408,
        -688
      ],
      "parameters": {
        "options": {},
        "operation": "completion",
        "completionTitle": "Workflow Exported",
        "completionMessage": "=Workflow: {{ $json.name }}. Has been successfully exported to the target system."
      },
      "typeVersion": 2.3
    },
    {
      "id": "3a08b321-f880-4c52-8fb2-2fc11e131f2a",
      "name": "Export Workflow no creds",
      "type": "n8n-nodes-base.n8n",
      "position": [
        5184,
        -688
      ],
      "parameters": {
        "operation": "create",
        "requestOptions": {},
        "workflowObject": "={\n  \"name\": \"{{ $json.name }}\", \n  \"nodes\": {{ $json.nodes.toJsonString() }}, \n  \"connections\": {{ $json.connections.toJsonString() }}\n}"
      },
      "credentials": {
        "n8nApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "20629054-d9e3-47c2-99c8-483b0a206087",
      "name": "Workflow Object no creds",
      "type": "n8n-nodes-base.set",
      "position": [
        4960,
        -688
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "b855598e-8c30-4c43-972b-2ee2b38b5f96",
              "name": "name",
              "type": "string",
              "value": "={{ $('Workflow to Export Ready').item.json.name }}"
            },
            {
              "id": "9b44976a-eaba-459a-b5e1-d13f191e6eb4",
              "name": "nodes",
              "type": "array",
              "value": "={{ $('Workflow to Export Ready').item.json.nodes }}"
            },
            {
              "id": "6209af8f-cb82-45eb-8731-a5913ecc43aa",
              "name": "connections",
              "type": "object",
              "value": "={{ $('Workflow to Export Ready').item.json.connections }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "8e6fd203-3d95-4023-9a2c-a2a5493ae395",
      "name": "Workflow Object",
      "type": "n8n-nodes-base.set",
      "position": [
        6528,
        -384
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "b855598e-8c30-4c43-972b-2ee2b38b5f96",
              "name": "name",
              "type": "string",
              "value": "={{ $json.name }}"
            },
            {
              "id": "9b44976a-eaba-459a-b5e1-d13f191e6eb4",
              "name": "nodes",
              "type": "array",
              "value": "={{ $json.nodes }}"
            },
            {
              "id": "6209af8f-cb82-45eb-8731-a5913ecc43aa",
              "name": "connections",
              "type": "object",
              "value": "={{ $json.connections }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "aae17446-f5cb-4e16-bc6e-b772ac9b03dc",
      "name": "Export Workflow",
      "type": "n8n-nodes-base.n8n",
      "position": [
        6752,
        -384
      ],
      "parameters": {
        "operation": "create",
        "requestOptions": {},
        "workflowObject": "={\n  \"name\": \"{{ $json.name }}\", \n  \"nodes\": {{ $json.nodes.toJsonString() }}, \n  \"connections\": {{ $json.connections.toJsonString() }}\n}"
      },
      "credentials": {
        "n8nApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "c4a6da2f-4bac-4828-b78d-698f5a27dfc5",
      "name": "Exported",
      "type": "n8n-nodes-base.form",
      "position": [
        6976,
        -384
      ],
      "parameters": {
        "options": {},
        "operation": "completion",
        "completionTitle": "Workflow Exported",
        "completionMessage": "=Workflow: {{ $json.name }}, successfully exported to the target system. Please verify on the target system that all credentials have been exported, that their configurations are correct, and that they are properly linked to the workflow.\n<br><br>\nCredentials Exported:<br>\n{{ $('Export Credentials').all().map(c => c.json.name).join(', ') }}"
      },
      "typeVersion": 2.3
    },
    {
      "id": "336f98aa-8f6b-467b-9124-58ac62be5d41",
      "name": "Sub-Workflows",
      "type": "n8n-nodes-base.code",
      "position": [
        1376,
        -592
      ],
      "parameters": {
        "jsCode": "const wf = $input.first().json;\nconst cleaned = [];\n\nfor (const node of wf.nodes || []) {\n  if (node.parameters && node.parameters.workflowId) {\n    const wfObj = node.parameters.workflowId;\n\n    if (!cleaned.find(c => c.id === wfObj.value)) {\n      cleaned.push({\n        id: wfObj.value,\n        name: wfObj.cachedResultName\n      });\n    }\n  }\n}\n\nreturn cleaned.map(c => ({ json: c }));\n"
      },
      "executeOnce": true,
      "typeVersion": 2,
      "alwaysOutputData": true
    },
    {
      "id": "79e8a3d3-d4b2-4d7d-9378-8e1700deac6b",
      "name": "Check Target Sub-Workflows",
      "type": "n8n-nodes-base.n8n",
      "position": [
        1824,
        -528
      ],
      "parameters": {
        "filters": {
          "name": "={{ $json.name }}"
        },
        "requestOptions": {}
      },
      "credentials": {
        "n8nApi": {
          "name": "<your credential>"
        }
      },
      "executeOnce": false,
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "71ef0769-ef28-4d69-b91c-4b36919a97ff",
      "name": "Check Target Workflows",
      "type": "n8n-nodes-base.n8n",
      "position": [
        256,
        -688
      ],
      "parameters": {
        "filters": {
          "name": "={{ $json['Workflow to export'] }}",
          "excludePinnedData": true
        },
        "requestOptions": {}
      },
      "credentials": {
        "n8nApi": {
          "name": "<your credential>"
        }
      },
      "executeOnce": true,
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "14031cd8-a476-44b6-babe-b3edabf34189",
      "name": "Missing Sub-workflows",
      "type": "n8n-nodes-base.code",
      "position": [
        2496,
        -528
      ],
      "parameters": {
        "jsCode": "const source = $('Sub-Workflows').all();\nconst target = $input.all();\n\nconst sourceNames = source.map(s => s.json.name);\nconst targetNames = target.map(t => t.json.name);\n\nconst missing = sourceNames.filter(n => !targetNames.includes(n));\n\nreturn {\n  json: {\n    missing\n  }\n};"
      },
      "typeVersion": 2,
      "alwaysOutputData": false
    },
    {
      "id": "5a6ddf29-9842-46fa-9e57-11b1575eac68",
      "name": "No Sub-Workflows",
      "type": "n8n-nodes-base.if",
      "position": [
        1600,
        -592
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "de821a7d-c0bf-4cfa-9bf3-5bf4c23f9e50",
              "operator": {
                "type": "object",
                "operation": "empty",
                "singleValue": true
              },
              "leftValue": "={{ $json }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "34ec9b90-cd85-4163-b346-1654a10781cf",
      "name": "Has Missing Sub-Workflows",
      "type": "n8n-nodes-base.if",
      "position": [
        2720,
        -528
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "fccace2b-1d29-451b-beca-29c2dbcc1f61",
              "operator": {
                "type": "array",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.missing }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "e22af903-1aac-4ae2-af95-667d132f2f65",
      "name": "Confirm Sub-Workflow",
      "type": "n8n-nodes-base.form",
      "position": [
        2944,
        -592
      ],
      "parameters": {
        "options": {
          "formTitle": "Sub-Workflows",
          "buttonLabel": "Next",
          "formDescription": "=Some sub-workflows referenced in this workflow were not found in the target system. You can either export them first and then continue this operation, or proceed now and adjust them manually later.\n<br><br>\nSub-Workflows Missing:<br>\n{{ $('Missing Sub-workflows').first().json.missing }}\n<br><br>\nSubWorkflows Found:<br>\n{{ $('Sub-Workflows Found').all().map(c => c.json.name).join(', ') }}\n"
        },
        "formFields": {
          "values": [
            {
              "fieldType": "radio",
              "fieldLabel": "Proceed with export?",
              "fieldOptions": {
                "values": [
                  {
                    "option": "Yes"
                  },
                  {
                    "option": "No"
                  }
                ]
              },
              "requiredField": true
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "07a362fc-306e-4355-980b-ba6d4fcae130",
      "name": "Abort",
      "type": "n8n-nodes-base.if",
      "position": [
        3168,
        -592
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "e4f8e108-baa5-4cc8-9dbd-007071c5f3e7",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json['Proceed with export?'] }}",
              "rightValue": "No"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "83238a08-3868-417f-aea5-61146fc2c660",
      "name": "No Sub-Workflow Found",
      "type": "n8n-nodes-base.if",
      "position": [
        3392,
        -592
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "807ff734-edb2-4aca-83fc-7d67a1ab7c31",
              "operator": {
                "type": "object",
                "operation": "empty",
                "singleValue": true
              },
              "leftValue": "={{ $('Sub-Workflows Found').item.json }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "43935843-cdfe-4650-9bc0-c845198b4503",
      "name": "Sub-Workflows Found",
      "type": "n8n-nodes-base.code",
      "position": [
        2272,
        -528
      ],
      "parameters": {
        "jsCode": "let subs = [];\nfor (const foundswf of $input.all()) {\n\n  for (const allswf of $('Sub-Workflows').all()) {\n    if (foundswf.json.name === allswf.json.name) {\n      subs.push({\n        id: foundswf.json.id,\n        oldid: allswf.json.id,\n        name: foundswf.json.name\n      });\n    }\n  }\n  \n}\n\nreturn subs;"
      },
      "typeVersion": 2,
      "alwaysOutputData": true
    },
    {
      "id": "7d5f0609-2b78-457a-9e87-f0389d7d9687",
      "name": "Fix Sub-Workflows Ids",
      "type": "n8n-nodes-base.code",
      "position": [
        3616,
        -480
      ],
      "parameters": {
        "jsCode": "let wf = JSON.stringify($('Workflow to Export').first());\n\nfor (const foundsubs of $('Sub-Workflows Found').all()) {\n  wf = wf.replaceAll(foundsubs.json.oldid, foundsubs.json.id);\n}\n\nreturn JSON.parse(wf);"
      },
      "typeVersion": 2
    },
    {
      "id": "4621b372-b162-416e-9766-108ab87691b0",
      "name": "Workflow to Export no Changes",
      "type": "n8n-nodes-base.code",
      "position": [
        3616,
        -720
      ],
      "parameters": {
        "jsCode": "return $('Workflow to Export').first();"
      },
      "typeVersion": 2
    },
    {
      "id": "33dbc2b7-ae28-495b-a4a9-f8eaba5866ca",
      "name": "Workflow to Export Ready",
      "type": "n8n-nodes-base.noOp",
      "position": [
        3840,
        -592
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "2d341822-54b0-4cf8-94c2-0a02af409c56",
      "name": "Exact Match 3",
      "type": "n8n-nodes-base.code",
      "position": [
        2048,
        -528
      ],
      "parameters": {
        "jsCode": "let swf = [];\nfor (const item of $input.all()) {\n  if (item.json.isArchived === false) {\n\n    for (const subs of $('Sub-Workflows').all()) {\n      if (subs.json.name === item.json.name) {\n        swf.push(item);\n      }\n    }\n    \n  }\n}\n\nreturn swf;"
      },
      "typeVersion": 2,
      "alwaysOutputData": true
    },
    {
      "id": "c58dfcaa-c4ee-4d52-8fd5-587d40f6aa27",
      "name": "Exact Match 1",
      "type": "n8n-nodes-base.code",
      "position": [
        480,
        -688
      ],
      "parameters": {
        "jsCode": "let crashes = [];\nfor (const item of $input.all()) {\n  if (item.json.isArchived === false) {\n\n    if ($('Workflow Selector').first().json['Workflow to export'] === item.json.name) {\n      crashes.push(item);\n    }\n    \n  }\n}\n\nreturn crashes;"
      },
      "typeVersion": 2,
      "alwaysOutputData": true
    },
    {
      "id": "276045b6-bdbf-4052-8a0f-d56c22f0c528",
      "name": "Exact Match 2",
      "type": "n8n-nodes-base.code",
      "position": [
        1152,
        -592
      ],
      "parameters": {
        "jsCode": "let match = [];\nfor (const item of $input.all()) {\n  if (item.json.isArchived === false) {\n\n    if ($('Workflow Selector').first().json['Workflow to export'] === item.json.name) {\n      match.push(item);\n    }\n    \n  }\n}\n\nreturn match;"
      },
      "typeVersion": 2,
      "alwaysOutputData": true
    },
    {
      "id": "1e6864a6-442e-41a3-b06a-7eceb030e3f7",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -720,
        -704
      ],
      "parameters": {
        "color": 3,
        "width": 256,
        "height": 224,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\nSet **SOURCE** n8n API Credential"
      },
      "typeVersion": 1
    },
    {
      "id": "e6e587fe-a977-4ae0-931a-6297ca10de9e",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        176,
        -704
      ],
      "parameters": {
        "color": 3,
        "width": 256,
        "height": 224,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\nSet **TARGET** n8n API Credential"
      },
      "typeVersion": 1
    },
    {
      "id": "701c6fb1-d6e1-4574-907b-205a30b0edf8",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        848,
        -608
      ],
      "parameters": {
        "color": 3,
        "width": 256,
        "height": 224,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\nSet **SOURCE** n8n API Credential"
      },
      "typeVersion": 1
    },
    {
      "id": "145e5c1e-b9b7-491d-986b-6beec0daa9d0",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1744,
        -544
      ],
      "parameters": {
        "color": 3,
        "width": 256,
        "height": 224,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\nSet **TARGET** n8n API Credential"
      },
      "typeVersion": 1
    },
    {
      "id": "2d0bb212-e14b-4dd8-a7e2-a2c487b95cf6",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        6000,
        -400
      ],
      "parameters": {
        "color": 3,
        "width": 256,
        "height": 224,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\nSet **TARGET** n8n API Credential"
      },
      "typeVersion": 1
    },
    {
      "id": "199a6ae8-50e6-4c4c-9962-47edc64c2513",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        6672,
        -400
      ],
      "parameters": {
        "color": 3,
        "width": 256,
        "height": 224,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\nSet **TARGET** n8n API Credential"
      },
      "typeVersion": 1
    },
    {
      "id": "09e658df-a830-46b2-989a-6a1faee91b40",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5104,
        -736
      ],
      "parameters": {
        "color": 3,
        "width": 256,
        "height": 224,
        "content": "Set **TARGET** n8n API Credential\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "aa604262-2a72-4973-bd85-632a10e97a9d",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5104,
        -496
      ],
      "parameters": {
        "color": 3,
        "width": 656,
        "height": 224,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\nFix the file paths according to your system"
      },
      "typeVersion": 1
    },
    {
      "id": "4305c7a3-91e1-4588-909a-03a76cd36f76",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        6000,
        -656
      ],
      "parameters": {
        "color": 3,
        "width": 256,
        "height": 224,
        "content": "Fix file path\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "e5467885-0226-4994-9b9e-bf26655a7432",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        144,
        -1568
      ],
      "parameters": {
        "width": 944,
        "height": 528,
        "content": "# Setup\nTo set up this workflow, you will need n8n API credentials for both of your systems: **SOURCE** and **TARGET**.  \nYou can find instructions on how to create credentials [here](https://docs.n8n.io/credentials/).  \nNodes that require configuration are highlighted in red.\n\n### n8n API\n- In your n8n settings, open the **n8n API** section from the sidebar.\n- Click **Create an API Key**. Give the key a name and save it. The key will only be shown once \u2014 make sure to copy it for the next steps.\n- Repeat these steps for both the SOURCE and TARGET systems. You will now have one API key for each.\n- Next, create credentials in the **SOURCE** system only:\n  - Add two new **n8n API** credentials using the keys you just created.\n  - Configure the server address for each.\n  - Create one credential for the SOURCE system and another for the TARGET system, each with its respective key and address.\n\n### System File Paths\n- Some nodes access the local file system of the SOURCE system.\n- The file paths currently configured are based on a default queue-mode Docker installation.\n- Review these paths and update them as needed to match your environment.\n\n\n\n\u2705 **Your workflow is ready!** Run this workflow on your SOURCE system to export workflows to the TARGET system.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "326d8c31-7883-48b0-afdb-ca4aaf98a5cc",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -832,
        -1568
      ],
      "parameters": {
        "width": 928,
        "height": 832,
        "content": "# Workflow Exporter\n\nThis workflow automates the process of copying workflows and credentials from one n8n server to another. It also checks whether the exported workflow requires adjustments for sub-workflow execution on the target system.\n\n## How It Works\n- **Workflow name check**: The system verifies if a workflow with the same name already exists in the target system. If it does, the export is stopped.\n- **Sub-workflow check**:  \n  - If the exported workflow calls other sub-workflows, the system checks if those sub-workflows already exist in the target system with the same names.  \n  - If all sub-workflows are found, the system updates the references so the exported workflow uses the sub-workflows in the target system and continues the export.  \n  - If any required sub-workflow is missing, the form will display this and give the user the option to cancel the export so they can fix it first.  \n  - If the user decides to continue anyway, the system will update the workflow using only the sub-workflows that exist in the target system (if any).  \n- **Credentials check**:  \n  - If the exported workflow does not contain nodes with credentials, the export completes normally.  \n  - If credentials are configured in the exported workflow, the form will display them and give the user the option to export them along with the workflow or export only the workflow.  \n  - Due to n8n and its API limitations, it is not possible to verify whether the credentials already exist in the target system. **See the blue note for details on credential export issues.**  \n  - The system can only apply corrections to credentials in the exported workflow if those credentials are exported together with it, since checking credentials already present in the target system is not possible.\n\n## Usage\nWhen you run this workflow, a form will appear.  \n- Click **Next** to start the export steps.  \n- The next form will display the workflows available in the source system.  \n- Select one to export and click **Next**.  \n- The form will then guide you through the export process step by step.  \n\n\n\n*(See the Setup section for instructions on how to configure this workflow.)*\n"
      },
      "typeVersion": 1
    },
    {
      "id": "8237f98e-4fca-49e1-aff7-744a429aba7e",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1136,
        -1568
      ],
      "parameters": {
        "color": 5,
        "width": 944,
        "height": 432,
        "content": "# Credential Issues and Limitations\n\nAs explained in the instructions, the system can only automatically update the exported workflow to use the credentials that are exported along with it.  \nDue to limitations in n8n and its API, it is not possible to check whether credentials already exist in the target system. In addition, some special cases may cause credential export to fail due to inconsistencies in the schemas of certain credential types.  \n\nBelow are the technical details of these issues:\n\n- The n8n API does not provide the ability to query credentials \u2014 only to create and delete them.  \n- This limitation prevents checking whether credentials already exist in the target system and also complicates copying them.  \n- To work around this, the **c8n-cli** utility is used in the source system. Credentials to be exported are first obtained through a local export in file format. This is the only way to retrieve the credential data.  \n- However, this method introduces technical inconsistencies with certain credential types.  \n- For some credentials, the fields obtained through **c8n-cli** are not consistent with the mandatory fields required by the n8n API when importing them into the target system.  \n- As a result, even if the user chooses to export credentials along with the workflow, some credentials may still fail during the process.  \n- After the export is complete, the form will list the credentials that were successfully exported.  \n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "d88d077f-7132-44ba-9f95-d25dedf56ae8",
  "connections": {
    "Abort": {
      "main": [
        [],
        [
          {
            "node": "No Sub-Workflow Found",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Exact Match 1": {
      "main": [
        [
          {
            "node": "Already Exists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Exact Match 2": {
      "main": [
        [
          {
            "node": "Sub-Workflows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Exact Match 3": {
      "main": [
        [
          {
            "node": "Sub-Workflows Found",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sub-Workflows": {
      "main": [
        [
          {
            "node": "No Sub-Workflows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Already Exists": {
      "main": [
        [
          {
            "node": "Workflow Name Clash",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Workflow to Export",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Dropdown": {
      "main": [
        [
          {
            "node": "Workflow Selector",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "No Credentials": {
      "main": [
        [
          {
            "node": "Workflow Object no creds",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Confirm Creds Export",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Export Workflow": {
      "main": [
        [
          {
            "node": "Exported",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Workflow Object": {
      "main": [
        [
          {
            "node": "Export Workflow",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Credentials List": {
      "main": [
        [
          {
            "node": "No Credentials",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "No Sub-Workflows": {
      "main": [
        [
          {
            "node": "Workflow to Export no Changes",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Check Target Sub-Workflows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Skip Credentials": {
      "main": [
        [
          {
            "node": "Workflow Object no creds",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Return Credentials List",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Archived 1": {
      "main": [
        [
          {
            "node": "Build Dropdown",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get all workflows": {
      "main": [
        [
          {
            "node": "Filter Archived 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Workflow Exporter": {
      "main": [
        [
          {
            "node": "Get all workflows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Workflow Selector": {
      "main": [
        [
          {
            "node": "Check Target Workflows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Export Credentials": {
      "main": [
        [
          {
            "node": "Fix Workflow Creds Ids",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Workflow to Export": {
      "main": [
        [
          {
            "node": "Exact Match 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Credentials to File": {
      "main": [
        [
          {
            "node": "Read Credentials Files",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sub-Workflows Found": {
      "main": [
        [
          {
            "node": "Missing Sub-workflows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Confirm Creds Export": {
      "main": [
        [
          {
            "node": "Skip Credentials",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Confirm Sub-Workflow": {
      "main": [
        [
          {
            "node": "Abort",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Credentials to Export": {
      "main": [
        [
          {
            "node": "Delete Credentials Files",
            "type": "main",
            "index": 0
          },
          {
            "node": "Export Credentials",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fix Sub-Workflows Ids": {
      "main": [
        [
          {
            "node": "Workflow to Export Ready",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Missing Sub-workflows": {
      "main": [
        [
          {
            "node": "Has Missing Sub-Workflows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "No Sub-Workflow Found": {
      "main": [
        [
          {
            "node": "Workflow to Export no Changes",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Fix Sub-Workflows Ids",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Target Workflows": {
      "main": [
        [
          {
            "node": "Exact Match 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fix Workflow Creds Ids": {
      "main": [
        [
          {
            "node": "Workflow Object",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Credentials Files": {
      "main": [
        [
          {
            "node": "Credentials Files to Json",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Return Credentials List": {
      "main": [
        [
          {
            "node": "Credentials to File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Export Workflow no creds": {
      "main": [
        [
          {
            "node": "Exported no creds",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Workflow Object no creds": {
      "main": [
        [
          {
            "node": "Export Workflow no creds",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Workflow to Export Ready": {
      "main": [
        [
          {
            "node": "Credentials List",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Credentials Files to Json": {
      "main": [
        [
          {
            "node": "Credentials to Export",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has Missing Sub-Workflows": {
      "main": [
        [
          {
            "node": "Confirm Sub-Workflow",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Fix Sub-Workflows Ids",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Target Sub-Workflows": {
      "main": [
        [
          {
            "node": "Exact Match 3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Workflow to Export no Changes": {
      "main": [
        [
          {
            "node": "Workflow to Export Ready",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This workflow contains community nodes that are only compatible with the self-hosted version of n8n.

Source: https://n8n.io/workflows/8620/ — original creator credit. Request a take-down →

More General workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

General

Credentials Transfer. Uses form, httpRequest, executeCommand, readWriteFile. Event-driven trigger; 22 nodes.

Form, HTTP Request, Execute Command +2
General

Are you writing complex Code nodes and need Intellisense support? Follow this simple pattern to get autocomplete for any n8n or custom classes.

n8n, Form Trigger, Form
General

This workflow uses AI to automatically generate clear and descriptive names for every node in your n8n workflows. It analyzes each node's type, parameters, and connections to create meaningful names,

n8n, Chain Llm, Output Parser Structured +4
General

This interactive tutorial teaches you how to build in n8n from scratch, using a live walkthrough with real-time examples. Rather than static documentation, this guided workflow explains key n8n concep

Form Trigger, Form
Data & Sheets

Workflow Importer. Uses extractFromFile, executeCommand, readWriteFile, httpRequest. Event-driven trigger; 58 nodes.

Execute Command, Read Write File, HTTP Request +3