Export, sanitise and re-import n8n workflows
Export a workflow, remove sensitive values, re-import it into a clean lab and reconnect its credentials.
By Invicly Tech, , in n8n, AI Automation and Voice Agents. About 9 minutes to read.
In short
A workflow can be exported as a JSON file and imported into another n8n. This lets you keep workflows in Git, share them and rebuild a lab from scratch. Before sharing, remove secrets and real data, and remember that credentials are not carried across: you reconnect them after import.
Explained simply
Once you have built a workflow, you will want to keep a copy, share it, or rebuild your lab from scratch. n8n can export a workflow as a JSON file. JSON is a plain text format that describes the nodes, their settings and how they connect.
An exported file is not the whole story. It names the credentials a node used, but it does not hold the secret values. After you import the file into another n8n, you connect new credentials to each node. This is a safety feature, and it also means a fresh lab needs a little set-up.
Before you share a file, read it. Real email addresses, webhook URLs, tokens pasted into settings or pinned data copied from real records can hide inside. Search for them and remove them. This is called sanitising.
Keep the export in Git, with a small sample input beside it. Anyone can then import the workflow, load the sample and check they get the same result. Also note the n8n version you used, because older versions may not open files made by newer ones.
Press Play on a diagram to walk through it one step at a time.
- 1Check n8n version and clean the dataSource lab to Source lab: Check n8n version and clean the data
- Source lab to Git repository: Export workflow JSON and sample input2Export workflow JSON and sample input
- Git repository to Clean lab: Clone and import the file3Clone and import the file
- 4Reconnect credentialsClean lab to Clean lab: Reconnect credentials
- 5Run with the sample inputClean lab to Clean lab: Run with the sample input
- 1Unpin real data
Replace with synthetic records
- 2Export JSON
Record the n8n version
- 3Search for secrets
token, secret, apikey, emails
- 4Add sample input
With the expected result
- 5Commit to Git
Review the diff first
In depth
Ways to export and import
In the editor, open the workflow menu and choose Download to save a JSON file. To import, use Import from File or Import from URL, or paste the JSON onto the canvas. You can also copy selected nodes with Ctrl+C and paste them into another workflow.
For many workflows, or for scripts, use the command line inside the container: n8n export:workflow --all --output=file.json and n8n import:workflow --input=file.json. The command line is handy for backups and for rebuilding a clean lab in one step. Check the docs for the flags your pinned release supports.
- Editor: Download and Import from File
- Copy and paste nodes between workflows
- CLI: export:workflow and import:workflow
- Check flags in the docs for your version
Version compatibility
Nodes have their own version numbers, and n8n itself changes. A workflow exported from a newer release may use a node version an older release does not have. The older n8n may refuse to open it or show a node as unknown. Importing into the same or a newer release is the safe direction.
That is why you record the pinned n8n tag with each export, for example in the file name or the README. When you upgrade, import your fixtures into a clean lab on the new tag and run the sample input to prove they still work.
- Best case
- Nodes and settings match
- Use for team labs
- Usually fine
- n8n can update node versions
- Run the sample input to confirm
- May fail or show unknown nodes
- Missing node versions
- Avoid or upgrade the target
Sanitise before you share
Treat an export like source code that will be read by strangers. Search the file for strings that look like secrets: token, secret, apikey, password and Authorization. Look for real email addresses, phone numbers and your own domain names. Check URLs, because a webhook path can act as a secret.
Pay special attention to pinned data. Pins are stored inside the workflow JSON, so a pin made while testing with a real record exports that record. Unpin and replace it with synthetic data before exporting. Also make sure you did not paste a key into an HTTP Request header parameter instead of using a credential.
- Search for token, secret, apikey, password
- Look for real emails and domains
- Unpin real data before export
- Use credentials, not header values
Sample inputs and credential reconnection
Ship a small file of synthetic input with each export, such as requests.json with five invented requests, two of them incomplete. State the expected result in the README: 5 in, 3 kept, 3 accepted by the fixture.
After import, open each node that shows a credential warning and pick or create the local credential. Use placeholders in a lab. Then run with the sample input and compare to the expected result. Do not activate triggers until this passes, or a webhook or schedule might start doing real work.
Learn it in 6 short steps
About 20m each. Track them with a timer in your plan.
- 1Export workflow JSON~20m
- 2Check version compatibility~20m
- 3Remove secrets and real data~20m
- 4Ship sample inputs with the export~20m
- 5Reconnect credentials after import~20m
- 6Keep exports in Git~20m
Key points
- Export from the workflow menu with Download, or use the n8n command line export:workflow command.
- The JSON names the credentials a node used but does not contain the secret values. You attach credentials again after import.
- Import into the same or a newer n8n version. Older versions may not know newer node versions.
- Search the file before sharing: real emails, webhook URLs, tokens pasted into parameters or pinned real data.
- Ship a small sample input next to the export and keep both in Git, so anyone can repeat your test.
Key terms
Tap a card to flip it. 0/5 known
Examples
docker exec n8n-lab n8n export:workflow --all --output=/home/node/.n8n/out.json
docker cp n8n-lab:/home/node/.n8n/out.json ./workflows/appointments.json
grep -n -i -E "token|secret|apikey|@[a-z0-9.-]+\.[a-z]+" workflows/appointments.json
# in the clean lab
docker cp ./workflows/appointments.json n8n-clean:/home/node/.n8n/in.json
docker exec n8n-clean n8n import:workflow --input=/home/node/.n8n/in.jsonExport and import with the n8n command line inside the lab container, then scan for leftovers.
Rebuild a clean lab from Git
You have a repository with workflows/appointments.json and data/requests.json. Start a second container on the same pinned tag, import the file, reconnect the placeholder credential and run. Evidence to expect: 5 items in, 3 after the Filter and 3 responses with status 200 from the fixture.
docker run -d --name n8n-clean -p 5680:5678 docker.n8n.io/n8nio/n8n:<version>
docker cp workflows/appointments.json n8n-clean:/tmp/in.json
docker exec n8n-clean n8n import:workflow --input=/tmp/in.json
# open http://localhost:5680, reconnect credentials, run with requests.json
# cleanup: docker rm -f n8n-cleanFind a leaked value before committing
A search of the export finds a long string next to the word Authorization. It came from a header typed directly into an HTTP Request node. Fix it by creating a credential, selecting it in the node, exporting again and confirming that the search finds nothing. Rotate the leaked value too, since it was in the file.
grep -n -i -E "authorization|token|secret|apikey|password" workflows/appointments.json
# fix in the editor: use a credential, then export again
grep -c -i "authorization" workflows/appointments.json # expect 0Quick reference
- Editor: workflow menu, Download. Import from File or URL.
- CLI: n8n export:workflow and n8n import:workflow.
- Exports name credentials but hold no secret values.
- Import into the same or a newer n8n release.
- Pins are exported too. Remove real data first.
- Ship sample input and the expected result with each export.
- Do not activate imported triggers before credentials are reconnected.
Common mistakes
- Committing an export with pinned real customer data inside it.
- Importing and activating a workflow before the credentials are reconnected.
- Assuming a file from a newer n8n will open in an older one.
Quick quiz
Pick an answer to see if you're right and why.
Practice exercises
Try each one yourself first. Use the hint if you get stuck, then compare with the solution.
- Exercise 1easy
Download your workflow from the editor and open the JSON. Find the nodes array and list the node names.
- Exercise 2medium
Search the file for secrets and real emails, and write what you found and what you did.
- Exercise 3hard
Rebuild the workflow in a second clean lab from the Git files only, and document the evidence and the cleanup.
Check yourself
Answer in your head, reveal, then be honest with yourself.
Feel confident about this topic?
Frequently asked questions
- Why are my credentials missing after import?
- Exports do not include secret values. Open each node and select or create a credential in the new instance.
- Can I keep exports in a public Git repository?
- Only after sanitising: no secrets, no real data, and a check of pinned data. When in doubt, use a private repository.
- Should I commit the whole n8n volume?
- No. It holds the encryption key and credentials. Commit exported workflow JSON and sample inputs only.