Create flows.json programmatically?

Let's assume I have 10 flows (in 10 tabs). I would like to programmatically create a new flows.json file for a subset of the flows, in order to run them in a second Node-RED instance. What's the recommended way how to do this?

I see two options:

  • parse original flows.json file and create a new flows.json with just a subset of the flows
  • call GET /flow/:id for the flows needed in the new file and manually create a new file of the the results

Any thoughts or suggestions, or any options I missed?

What are the rules for creating the subset?

No fixed rule. Just assume I would choose tabs with names x, y and z.

  1. Export the flow
  2. shut down node-red
  3. start node-red using a new name
  4. import the flow you exported
  5. delete the tabs you don’t want
  6. export that flow
  7. stop and start node-red

Your original flow should now be running and in the node-red folder you should see the new flow without the tabs you got rid of.

I tried this in the past and it works, however, as mentioned in the title, I would like to do this programmatically.

I suggest this, it should be achievable with a series of requests using the HTTP Request node, finishing off with the Write File node - removing the need to do anything manual.

Thanks @marcus-j-davies . JFYI: it's not requirement to do it from a flow itself, it's completely fine to do it from outside Node-RED. However, in case I can do it from Node-RED I will also be able to do it from the outside.

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.