Subworkflow Dependency Graph Generator and Auto-Tagging - n8n Workflow

Analyze your n8n instance dependency structure. This n8n workflow automatically generates a visual dependency graph and applies tags to subworkflows based on their callers, streamlining maintenance.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • n8n DevOps Engineers: Individuals responsible for maintaining large, complex n8n environments with many interconnected n8n workflow deployments.

  • Technical n8n Users: Anyone needing precise documentation of which parent n8n workflow calls a specific subworkflow.

  • Automation Architects: Users focused on optimizing workflow structure, preventing breaking changes, and visualizing the execution flow within their n8n instance.

  • Developers leveraging n8n templates: Users who frequently import complex n8n templates and need clarity on internal API interactions.

Overview

Managing a growing number of interconnected n8n workflows often leads to maintenance nightmares, especially when dependencies are opaque. This advanced n8n workflow solves this critical operational challenge by automatically discovering and documenting subworkflow relationships. By utilizing the n8n API, the system identifies every instance where one n8n workflow calls another (a subworkflow). It then proceeds to automatically tag these subworkflows with the unique IDs of their 'caller' workflows. This auto-tagging feature ensures that when you view a subworkflow, you instantly know every other n8n workflow that relies on it. Furthermore, the workflow generates visual dependency graphs and usage charts, providing indispensable monitoring and visualization capabilities for any large-scale n8n deployment. This complete n8n solution turns workflow maintenance into an efficient, documented process.

How it Works

The n8n automation is designed to run via multiple n8n trigger mechanisms: manually via a webhook, on a schedule (every Sunday), or upon activation of the n8n workflow itself.


  1. Data Collection: The process starts with the n8n node, which uses the n8n API to retrieve a list of all deployed n8n workflows in the instance.

  2. Dependency Mapping: A powerful Code n8n node, named 'List callers of subworkflows', processes this list. It inspects the JSON of every n8n workflow, specifically looking for Execute Workflow or Langchain toolWorkflow nodes. It then maps the caller workflow ID to the called subworkflow ID, establishing the dependency graph.

  3. Filtering: Subsequent Filter n8n nodes ensure that only workflows actively called by others (true subworkflows) and those that actually exist in the instance are passed forward for processing.

  4. Auto-Tagging Logic: The data is split into batches, and for each subworkflow, the automation determines which callers are not currently applied as tags. Using multiple HTTP Request n8n nodes, the system checks for existing tags and creates new tags where the name is the ID of the calling n8n workflow. Finally, another HTTP Request n8n node updates the subworkflow by assigning these new tags, effectively linking the subworkflow back to its dependencies.

  5. Visualization: On a separate path, the n8n workflow aggregates caller counts to generate a pie chart via the QuickChart n8n node (showing usage frequency) and uses custom HTML/MermaidJS rendered via the Respond to Webhook n8n node to display a visual dependency graph when the webhook n8n trigger is executed.

Installation Guide

To deploy this comprehensive n8n workflow template and enable auto-tagging and visualization for your instance, follow these steps:


  1. Import the n8n Workflow: Copy the provided JSON data and paste it into your n8n instance using the 'New' button and selecting 'Import from JSON'.

  2. Set up n8n API Credentials: This n8n workflow relies on being able to interact with the n8n API to list workflows, get tags, create tags, and update workflows. You must configure an 'n8n API' credential with full access permissions. Apply this credential to all relevant nodes (e.g., GET all workflows, Update workflow tags).

  3. Configure Instance URL: Locate the 'SET instanceurl' n8n node (highlighted in red in the original workflow sticky note). You must replace the placeholder value (https://n8n.example.com) with the actual base URL of your n8n instance. This is crucial for the HTTP Request n8n node operations to manage tags and workflows.

  4. Execution: Activate the n8n workflow. It will run on activation, every Sunday via the Schedule n8n trigger, or manually by accessing the webhook URL provided by the 'When viewed in a browser' n8n trigger (e.g., YOURN8N_URL/webhook/dependency-graph).

Node Details


  • GET all workflows (n8n node): Serves as the initial data source. It performs a basic API call to retrieve the configuration data (including nodes and existing tags) for every n8n workflow in the instance.

  • List callers of subworkflows (Code n8n node): This is the core logic engine. It analyzes the JSON structure of all retrieved n8n workflows to identify n8n node types that execute other workflows, building the dependency relationships (callers map).

  • Exclude uncalled workflows & Exclude missing workflows (Filter n8n node): Used to sanitize the dependency graph, ensuring that only actively called subworkflows are processed for tagging, thereby optimizing the n8n workflow execution time.

  • Update workflow tags (HTTP Request n8n node): Performs a PUT request to the n8n API (/api/v1/workflows/{id}/tags). This is the final step in the auto-tagging loop, where the subworkflow is updated with a list of tag IDs corresponding to its callers.

  • Visualize dependency graph with MermaidJS (Respond to Webhook n8n node): Used primarily when triggered manually. It embeds custom HTML and JavaScript (MermaidJS) containing the dependency graph structure generated by the preceding Code n8n node, providing a live, visual representation of the n8n workflow dependencies in the browser.

Related n8n Workflows

Free

Nodes: 16 Nodes
Updated: December 26 2025
View all
Created by

If you have any questions about any of the templates I've built, please reach out to me on LinkedIn (https://www.linkedin.com/in/ludwiggerdes) or via my website down below. 👇

Featured*