Tips > Building Workflows

Version Your Workflows Using Workflow History or Git

n8n makes it easy to modify workflows in-place, but without versioning, a bad edit can destroy a working automation with no way to roll back.

n8n lets you edit workflows in place, so without versioning a bad edit can destroy a working automation with no way back. Two options protect you: built-in Workflow History, which snapshots every save and restores any previous version, and Git-based version control that exports each workflow (minus credential secrets) through the n8n REST API on a schedule.

Why version your n8n workflows?

n8n makes it easy to modify workflows in-place, but without versioning, a bad edit can destroy a working automation with no way to roll back. n8n provides built-in workflow history (execution-linked snapshots) and, for advanced teams, Git-based version control via the n8n API.

Real-world example: Setting up Git-based workflow version control using n8n's REST API and a scheduled backup workflow.

How do you back up workflows to Git with the n8n API?

Automated backup workflow that runs daily:

[Schedule Trigger: Daily 2 AM]
    → [HTTP Request: GET /api/v1/workflows]
    → [Code: Process each workflow]
    → [HTTP Request: Commit to Git repo]

Code node to export all workflows:

const workflows = $input.all();
const exports = [];

for (const wf of workflows) {
  const workflow = wf.json;

  // Sanitize: remove execution data and credential secrets
  const sanitized = {
    id: workflow.id,
    name: workflow.name,
    nodes: workflow.nodes,
    connections: workflow.connections,
    settings: workflow.settings,
    tags: workflow.tags,
    // Exclude: staticData, credentials (contain secrets)
  };

  exports.push({
    json: {
      filename: `workflows/${workflow.id}_${workflow.name.replace(/[^a-zA-Z0-9]/g, '_')}.json`,
      content: JSON.stringify(sanitized, null, 2)
    }
  });
}

return exports;

What does n8n's built-in Workflow History offer?

For teams using n8n's built-in history (available in newer versions):

Workflow History features:
- Automatic snapshots on every save
- Compare versions side-by-side
- Restore any previous version with one click
- History retention configurable (default: 30 days)

Access: Workflow canvas → "..." menu → "Workflow History"

Warning: Credentials Are Not Versioned. Workflow exports (JSON) intentionally exclude credential secrets. After restoring a workflow from backup, you must re-select the correct credentials for each node. Document which credentials each workflow uses in a Sticky Note.

How should you name workflow version commits?

Git-based versioning with a naming convention for commit messages:

Convention: [workflow-id] [action] [description]

Examples:
  [wf-42] update Added retry logic to payment node
  [wf-42] rollback Reverted to pre-migration version
  [wf-15] create New lead scoring workflow
  [wf-15] deprecate Replaced by wf-67

Versioning is insurance. The cost is near zero and the value is infinite the first time you need to roll back a broken change.

Related: Always Set an Error Workflow on Every Production Workflow · Use "Pin Data" to Freeze Node Output

Showcase builds

19 complete workflows from my own projects, each with its n8n workflow JSON to import. Showcase entries link the file at the end of the article.

See the showcase builds

Keep reading

190 entries grouped by topic, from first workflow to queue mode. Free, no signup.

Browse the encyclopedia

Need it built?

I design, build and run n8n systems for clients. Every engagement starts with a $1,500 diagnostic audit, credited toward the build.

Book an introductory call