Automated Documentation Generation for Workflows using GPT and Docsify - n8n Workflow

Use this powerful n8n workflow template to automatically generate and serve dynamic Markdown documentation for all your existing n8n workflows using GPT-4 and Docsify. Includes a live Markdown editor.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • n8n users running self-hosted instances who need centralized, readable documentation.

  • Automation teams requiring auto-generated technical documentation for every n8n workflow.

  • Developers looking for advanced n8n templates integrating AI agents and web hooks for serving dynamic content.

  • Anyone managing a large portfolio of n8n nodes and needing an efficient way to document their purpose and configuration.

Overview

Managing documentation for numerous automations can be time-consuming. This n8n workflow solves this by acting as a dynamic documentation server, leveraging the power of an AI Large Language Model (LLM) to instantly generate detailed documentation for any existing n8n workflow.

This robust n8n workflow integrates with the Docsify JS library, serving an interactive documentation site directly from your n8n instance. When a user requests documentation for a specific n8n workflow, the system checks if a Markdown file exists. If it doesn't, or if the user requests a 'recreate' action, the workflow fetches the target workflow's JSON data, generates a Mermaid schematic diagram using a custom n8n node, and feeds both into an OpenAI model (via Langchain nodes). The AI generates structured, technical documentation, which is then saved locally. The entire system supports viewing, live editing with a Markdown preview, and saving the resulting document, making it an essential n8n template for governance and knowledge sharing.

How it Works

This automation operates primarily through two webhook n8n trigger nodes acting as an API endpoint for the Docsify front-end.


  1. Initialization: The primary webhook trigger serves the main index.html page, which loads the Docsify library.

  2. Routing & File Check: A secondary n8n trigger catches all subsequent requests for Markdown files (like README.md, summary.md, or specific workflow documents).

  3. Content Serving: For general pages (README.md, summary.md), the workflow queries the n8n API to list all available n8n workflows or tags, compiling them into a Markdown table or navigation pane.

  4. Workflow Document Handling: When a specific documentation page (docs_workflowId.md) is requested, the system checks the local disk for the existing file.

  5. AI Generation (If needed): If the file is missing or a 'recreate' action is chosen, the n8n workflow fetches the target workflow's JSON. A custom Code n8n node generates a visual Mermaid flowchart diagram of the internal logic and connection types. This chart, alongside the raw workflow structure, is passed to the OpenAI Chat Model using Langchain n8n nodes for structured documentation generation.

  6. Editing and Saving: If the 'edit' action is requested, the workflow serves a custom HTML page containing a live Markdown editor (also powered by Docsify preview). Upon saving, a POST request is handled by the n8n trigger, which updates the local Markdown file using the Save New Doc File n8n node.

Installation Guide


  1. Import the n8n workflow: Copy the provided JSON and import it into your n8n instance.

  2. Credentials Setup:

Set up two n8n API Credentials (used by the n8n nodes) pointing back to your instance to allow the workflow to read other workflow definitions and tags.
Set up one OpenAI API Credential (used by the OpenAI Chat Model n8n node) for documentation generation.

  1. Configuration: Edit the CONFIG Set n8n node (ID: f41906c3-ee4c-4333-bfd5-426f82ba4bd9):

Set projectpath: Define a writable directory where Markdown files will be stored (e.g., ./.n8n/testdocs).
Set instance_url: Ensure this correctly reflects the publicly accessible URL of your n8n instance.

  1. Activation: Activate the n8n workflow. The main Docsify interface is accessible via the URL provided by the docsify webhook trigger.

Node Details


  • Webhook Trigger (docsify, single workflow): The primary n8n trigger points that handle all incoming HTTP requests from the Docsify client, routing requests for the main page, tag lists, and individual documentation files.

  • CONFIG (Set n8n node): Stores critical global configuration variables, including file paths, instance URL, and necessary HTML/CSS boilerplate for the Docsify interface.

  • n8n Node (Get All Workflows, Get Workflow tags, Fetch Single Workflow): These n8n nodes query the n8n API itself to retrieve data about existing n8n workflow names, statuses, tags, and complete JSON structures. Used to dynamically build the index and sidebar.

  • Code n8n Node (Generate Mermaid Chart): Custom scripting that analyzes the JSON structure of a target n8n workflow and generates a Mermaid diagram string, visually mapping out the flow of n8n nodes and connections.

  • Basic LLM Chain (Langchain): Manages the process of generating documentation. It includes the logic for input text, strict instructions, and output parsing, ensuring the AI focuses on generating useful content about the n8n nodes and their configurations.

  • OpenAI Chat Model (gpt-4-turbo): The core AI component that processes the workflow JSON and documentation instructions to generate comprehensive Markdown content, fulfilling the documentation creation task.

  • Read/Write File (Load Doc File, Save New Doc File): Handles persistence, allowing the workflow to load existing, manually edited documentation or save newly generated/edited files to the defined project_path.

  • HTML n8n Node (Main Page, Edit Page): Used to construct and serve the necessary HTML pages. Edit Page contains the bespoke JavaScript for the live Markdown editor and saving functionality, crucial for maintaining and editing generated n8n templates documentation.

Related n8n Workflows

Free

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

Featured*