A command-line tool that performs bulk find-and-replace operations across all workflows in an n8n instance. Useful for updating API endpoints, URLs, config values, or any other string that appears in workflow JSON.
- Arbitrary Search & Replace: Find and replace any string across all workflows
- Multiple Replacements: Many-to-one or paired find/replace in a single run
- Dry Run Mode: Preview changes before applying (default)
- Connection Test: Verify API connectivity with
--test - Rich Console Output: Beautiful progress tracking and reporting
- Safe Operations: Confirmation prompts and error handling
- Clone and install:
git clone <repo-url>
cd n8n-workflow-search-replace
pip install -r requirements.txt- Configure
.env:
cp .env.example .env
# Edit .env with your n8n details- Run:
# Test connectivity
python n8n_search_replace.py --test
# Preview changes (dry run)
python n8n_search_replace.py --find "api.old-domain.com" --replace "api.new-domain.com"
# Apply changes
python n8n_search_replace.py --find "api.old-domain.com" --replace "api.new-domain.com" --liveCreate a .env file with the following variables:
# N8N API Configuration
N8N_API_KEY=your_n8n_api_key_here
N8N_BASE_URL=your_n8n_instance_url_here- Log into your n8n instance
- Go to Settings -> Personal -> API Keys
- Click Create API Key
- Copy the generated key to your
.envfile
Note: n8n uses a custom header format X-N8N-API-KEY (not standard Bearer tokens).
python n8n_search_replace.py --testVerifies API connectivity and reports the number of workflows on the instance.
python n8n_search_replace.py --find "api.old-domain.com" --replace "api.new-domain.com"python n8n_search_replace.py \
--find "staging.example.com" \
--find "dev.example.com" \
--replace "prod.example.com"python n8n_search_replace.py \
--find "api.old-domain.com" --replace "api.new-domain.com" \
--find "v1/endpoint" --replace "v2/endpoint" \
--liveStarting bulk search & replace:
staging.example.com -> prod.example.com
Target instance: https://n8n.example.com
Running in DRY RUN mode - no changes will be made
Successfully connected to N8N API
Instance: https://n8n.example.com
Workflows: 86
Found 86 workflows
Workflows to Update
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃ Name ┃ ID ┃ Active ┃ Matches Found ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ My Workflow │ abc123... │ Yes │ staging.example.com │
└──────────────┴──────────────┴────────┴─────────────────────┘
Found 1 workflows to update
DRY RUN COMPLETE - Use --live to apply changes
- Connects to your n8n instance using the API key
- Fetches all workflows from the instance
- Scans each workflow's JSON for the search strings
- Replaces found strings with their replacements
- Updates workflows back via the n8n API
The tool performs find-and-replace on the serialized workflow JSON, ensuring all occurrences are updated.
- Cause: Invalid or missing n8n API key
- Solution:
- Verify your API key is correct in
.env - Ensure the API key hasn't expired
- Check that you have proper permissions in n8n
- Verify your API key is correct in
- Cause: Network connectivity or URL misconfiguration
- Solution:
- Run
python n8n_search_replace.py --testto diagnose - Verify your n8n instance URL in a browser
- Check if your n8n instance is accessible from your network
- Run
- Cause: No workflows contain the search strings
- Solution: Verify your
--findvalues match exactly what appears in the workflow JSON
- API Keys: Never commit your
.envfile to version control - Private Directory: The
private/folder is gitignored for additional secrets
n8n-workflow-search-replace/
├── n8n_search_replace.py # Main script
├── pyproject.toml # Project metadata & packaging
├── requirements.txt # Python dependencies
├── .env.example # Environment template
├── .env # Your secrets (gitignored)
├── .gitignore # Git ignore rules
└── README.md # This file
Based on N8N-LLM-Workflow-Bulk-Updater by Daniel Rosehill.