TokenMix Research Lab · 2026-06-05

n8n Workflow JSON 2026: Import, Export, CLI, Template Fixes
Last Updated: 2026-06-05 Author: TokenMix Research Lab Data verified: 2026-06-05 - n8n official export/import docs, CLI commands, workflow templates, n8n CLI beta docs, public API docs, saving/publishing, workflow history, and data docs
n8n workflows are saved in JSON format. You can import/export from the editor, URL, file, server CLI, or n8n CLI, but credentials, active state, and workflow versions are the traps.
n8n's official docs say workflows are saved in JSON format and can be exported as JSON files or imported into the n8n library through copy-paste, the editor menu, file import, URL import, or command line tools (n8n export/import). Exported workflow JSON can include credential names and IDs, and n8n warns that HTTP Request nodes imported from cURL may contain authentication headers, so shared JSON should be anonymized first (n8n export/import). The server CLI supports n8n export:workflow --id=<ID> --output=file.json and n8n import:workflow --input=file.json, while the newer n8n-cli can create workflows from JSON but is marked beta and not for production workflows (n8n CLI commands, n8n CLI).
Table of Contents
- Quick Verdict
- Import and Export Methods
- CLI Commands
- Workflow JSON Safety
- Template JSON
- Version and Active State
- Common JSON Fixes
- Developer Checklist
- Risks and Caveats
- Final Recommendation
- FAQ
- Sources
- Related Articles
Quick Verdict
| Claim | Status | Source |
|---|---|---|
| n8n saves workflows in JSON format | Confirmed | Export/import docs |
| n8n can import workflow JSON from URL | Confirmed | Export/import docs |
| n8n can import workflow JSON from file | Confirmed | Export/import docs |
| Exported workflow JSON can include credential names and IDs | Confirmed | Export/import docs |
| Credential IDs are API secrets | False | n8n says IDs are not sensitive, but names could be |
| HTTP Request nodes imported from cURL may contain authentication headers | Confirmed | Export/import docs |
n8n export:workflow --id=<ID> --output=file.json exports a workflow |
Confirmed | CLI commands |
n8n import:workflow --input=file.json imports a workflow |
Confirmed | CLI commands |
| n8n CLI is recommended for production workflow management | False | n8n says n8n CLI is beta and not for production workflows |
| Importing active workflows always preserves active state | False | Default import deactivates workflows; --activeState=fromJson has mode limits |
| Workflow history versions can be downloaded as JSON | Confirmed | Workflow history |
| More teams will version n8n JSON in Git as workflows become production code | Speculation | n8n supports JSON export, but adoption trend is inferred |
Import and Export Methods
| Method | Direction | Best for | Main caveat | Status |
|---|---|---|---|---|
| Copy-paste nodes | Import/export partial workflow | Quick local edits | Easy to lose context | Confirmed |
| Editor Download | Export | Manual backup or sharing | Check credentials and headers | Confirmed |
| Import from File | Import | Local JSON workflow file | May overwrite IDs in some contexts | Confirmed |
| Import from URL | Import | GitHub-hosted template JSON | Trust source before importing | Confirmed |
| Server CLI | Import/export | Self-hosted backup/migration | Operates on database; restart may be needed | Confirmed |
| n8n CLI | API-based management | Local dev and experiments | Beta, not production | Confirmed |
| Public REST API | Programmatic management | Custom apps and workflows | Not available during free trial | Confirmed |
If your target is model routing inside n8n, pair this with n8n OpenAI-Compatible API 2026. If your target is gateway cost control, use AI API Gateway 2026.
CLI Commands
| Task | Command | Note | Status |
|---|---|---|---|
| Export all workflows | n8n export:workflow --all |
Writes to stdout unless output specified | Confirmed |
| Export one workflow | n8n export:workflow --id=<ID> --output=file.json |
Good for one workflow backup | Confirmed |
| Export all to one file | n8n export:workflow --all --output=backups/latest/file.json |
Useful for snapshots | Confirmed |
| Export backup files | n8n export:workflow --backup --output=backups/latest/ |
Uses backup behavior | Confirmed |
| Export version | n8n export:workflow --id=<ID> --version=<VERSION_ID> --output=workflow-v1.json |
Specific historical version | Confirmed |
| Export published version | n8n export:workflow --id=<ID> --published --output=published.json |
Production version, not current draft | Confirmed |
| Import file | n8n import:workflow --input=file.json |
Default deactivates imported workflow | Confirmed |
| Import directory | n8n import:workflow --separate --input=backups/latest/ |
Imports separate JSON files | Confirmed |
| Preserve active state | --activeState=fromJson |
Only supported in multi-main and queue mode | Confirmed |
Cost calculation 1: if a workflow import accidentally leaves a production cron trigger running for one hour at 60 executions/hour, and each execution calls a $0.02 AI step, the mistake costs $1.20. That is not a n8n license fee; it is downstream API waste caused by bad import hygiene.
Workflow JSON Safety
| JSON field or content | Risk | What to do | Status |
|---|---|---|---|
| Credential names | Can reveal vendor, customer, environment, or account labels | Rename before sharing public JSON | Confirmed |
| Credential IDs | n8n says IDs are not sensitive | Still avoid leaking internal mapping if unnecessary | Confirmed |
| HTTP Request auth headers | Can expose tokens if imported from cURL | Strip headers before sharing | Confirmed |
| Active flag | Imported workflow may execute unexpectedly depending on mode | Import inactive by default, publish deliberately | Confirmed |
| Version metadata | Preserved on import for exported versions | Keep for audit, remove for public templates if needed | Confirmed |
| Node parameters | May include URLs, IDs, prompts, or customer metadata | Review before publishing | Likely |
| Test data | May include private payloads | Remove sample executions before sharing | Likely |
Minimal cleanup script for public template review:
import json
with open("workflow.json", "r", encoding="utf-8") as f:
workflow = json.load(f)
for node in workflow.get("nodes", []):
node.pop("credentials", None)
params = node.get("parameters", {})
if isinstance(params, dict):
for key in list(params):
if "authorization" in key.lower() or "header" in key.lower():
params[key] = "[REDACTED]"
workflow["active"] = False
with open("workflow.public.json", "w", encoding="utf-8") as f:
json.dump(workflow, f, indent=2)
Template JSON
| Template path | What it returns | Use case | Status |
|---|---|---|---|
/templates/workflows/<id> |
Template metadata and workflow in workflow key |
Preview/browsing | Confirmed |
/workflows/templates/<id> |
Workflow data to import onto canvas | Direct workflow import | Confirmed |
/templates/search |
Template search results | Custom library search | Confirmed |
/templates/collections/<id> |
Specific collection | Curated groups | Confirmed |
/templates/categories |
Categories | Browse/filter | Confirmed |
/health |
Health check | Custom template host monitoring | Confirmed |
n8n warns that the two workflow template endpoints require different response formats. If your custom template host returns the wrong shape, preview may work while canvas import fails.
Version and Active State
| Feature | Behavior | Why it matters | Status |
|---|---|---|---|
| Autosave | Edits save automatically, typically within 1-5 seconds | Draft changes exist before publish | Confirmed |
| Publish | Makes workflow live and locks production to a version | Production uses published version, not latest draft | Confirmed |
| Published export | --published exports active production version |
Avoid exporting untested draft | Confirmed |
| Version export | --version=<VERSION_ID> exports historical version |
Reproducible rollback artifact | Confirmed |
| Import default active state | Imported workflows are deactivated by default | Safer migration | Confirmed |
--activeState=fromJson |
Uses JSON active field in supported modes | Useful for controlled restore | Confirmed |
| Cron import known issue | Cron triggers may keep running on non multi-main until restart | Restart after import when needed | Confirmed |
Common JSON Fixes
| Symptom | Likely cause | Fix | Status |
|---|---|---|---|
| Import fails with existing ID conflict | Exported workflow includes IDs already present | Change or remove IDs before import | Confirmed |
| Workflow imports but does not run | Default deactivation | Publish or activate deliberately | Confirmed |
| Cron trigger runs unexpectedly | Known import behavior on non multi-main | Restart and verify active state | Confirmed |
| Credential missing after import | Credentials are separate from workflow JSON | Recreate or import credentials safely | Confirmed |
| Public JSON leaks secrets | Headers or credentials included | Redact before sharing | Confirmed |
| Template preview works but import fails | Wrong endpoint response shape | Match n8n template schema requirements | Confirmed |
| SQLite migration name error | n8n name limit vs SQLite behavior | Rename in UI or edit JSON | Confirmed |
Cost calculation 2: a broken import that requires one engineer to manually rebuild 20 nodes at 5 minutes per node burns about 100 minutes. Exporting clean JSON and testing import in a staging instance is cheaper than reconstructing a workflow from screenshots.
Developer Checklist
| Step | Action | Pass condition |
|---|---|---|
| 1 | Export published version if backing up production | JSON reflects live workflow |
| 2 | Redact credentials and auth headers | No secret values or sensitive names |
| 3 | Set active false for public templates |
Import cannot run accidentally |
| 4 | Validate JSON parse | File loads with json.load |
| 5 | Import into staging first | Nodes render and execute with test credentials |
| 6 | Recreate credentials | No missing credential errors |
| 7 | Publish deliberately | Production version selected |
| 8 | Restart if server CLI changes require it | Runtime reflects database changes |
| 9 | Save JSON in Git | Reviewable workflow changes |
| 10 | Add README | Inputs, credentials, variables, and expected outputs documented |
Risks and Caveats
| Risk | What breaks | Mitigation | Status |
|---|---|---|---|
| Sharing credentials | Secrets or account labels leak | Redact and rename | Confirmed |
| Import overwrites existing IDs | Existing workflow changes unexpectedly | Edit IDs or import into clean environment | Confirmed |
| Draft vs published confusion | Wrong version backed up | Use --published for production |
Confirmed |
| CLI used in production incorrectly | Beta tool surprises | Use server CLI/API path appropriate to environment | Confirmed |
| Free trial API assumption | Public REST API unavailable | Upgrade or use supported import path | Confirmed |
| Cron trigger surprise | Duplicate executions | Import inactive, restart, verify triggers | Confirmed |
| Template schema mismatch | Custom template library fails | Match endpoint formats exactly | Confirmed |
Final Recommendation
Treat n8n workflow JSON as production code. Export the published version, redact credentials, import into staging, keep workflows inactive until reviewed, and use CLI/API paths only when their environment limits match your deployment.
FAQ
Are n8n workflows stored as JSON?
Yes. n8n says workflows are saved in JSON format and can be exported or imported as JSON files.
How do I export an n8n workflow JSON file?
Use the editor Download option or run n8n export:workflow --id=<ID> --output=file.json on the server CLI. Use --published if you need the live production version.
How do I import n8n workflow JSON?
Use Import from File, Import from URL, copy-paste in the editor, or n8n import:workflow --input=file.json. Test in staging before production.
Does n8n workflow JSON include credentials?
It can include credential names and IDs. n8n says IDs are not sensitive, but names can be. HTTP Request nodes imported from cURL may contain auth headers.
Does importing JSON activate the workflow?
By default, imported workflows are deactivated. --activeState=fromJson can preserve active state only in supported multi-main and queue-mode setups.
Can I use n8n CLI for production?
n8n says the newer n8n CLI is beta and should not be used for production workflows. Use the appropriate server CLI or API route for production environments.
Why does my n8n template URL import fail?
Custom template hosts have two different workflow endpoint formats. /templates/workflows/{id} includes workflow inside a workflow key, while /workflows/templates/{id} returns the workflow itself.
Should I put n8n workflow JSON in Git?
Yes for production teams. Versioning JSON makes workflow changes reviewable, but you must redact credentials, auth headers, customer data, and environment-specific IDs first.
Sources
- n8n Export and Import Workflows - official JSON import/export methods and credential safety notes
- n8n CLI Commands - official server CLI export/import workflow commands
- n8n Workflow Templates - official template endpoint formats and custom library requirements
- n8n Public REST API - official REST API availability and usage context
- n8n CLI - official beta CLI warning and workflow JSON creation context
- n8n Saving and Publishing Workflows - official autosave, publish, and production version behavior
- n8n Workflow History - official workflow version history and JSON download context
- n8n Data Overview - official JSON/table/schema data inspection context
Related Articles
- n8n OpenAI-Compatible API 2026: Workflow Setup And Costs
- Dify OpenAI-Compatible API 2026: Workflow Model Routing
- AI API Gateway 2026: Routing, Fallbacks, Observability, and Cost Control
- OpenAI API Cost 2026: GPT-5.5, 5.4, Nano, 50% Batch Savings
- TokenMix vs OpenRouter vs Portkey vs LiteLLM: 2026 Cost Guide