# Create flows.json programmatically?

**URL:** https://discourse.nodered.org/t/create-flows-json-programmatically/81934
**Category:** General
**Created:** [10 October 2023 19:25 UTC](https://discourse.nodered.org/t/create-flows-json-programmatically/81934 "2023-10-10T19:25:26Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Dunken](https://avatars.discourse-cdn.com/v4/letter/d/45deac/32.png) [@Dunken](https://discourse.nodered.org/u/Dunken)
#### Post date: [10 October 2023 19:25 UTC](https://discourse.nodered.org/t/create-flows-json-programmatically/81934/1 "2023-10-10T19:25:26Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)
#### Post date: [10 October 2023 19:29 UTC](https://discourse.nodered.org/t/create-flows-json-programmatically/81934/2 "2023-10-10T19:29:39Z")

</div>

What are the rules for creating the subset?

---

<div class="post-metadata">

### Author: ![Dunken](https://avatars.discourse-cdn.com/v4/letter/d/45deac/32.png) [@Dunken](https://discourse.nodered.org/u/Dunken)
#### Post date: [10 October 2023 19:32 UTC](https://discourse.nodered.org/t/create-flows-json-programmatically/81934/3 "2023-10-10T19:32:18Z")

</div>

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

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [10 October 2023 20:19 UTC](https://discourse.nodered.org/t/create-flows-json-programmatically/81934/4 "2023-10-10T20:19:06Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Dunken](https://avatars.discourse-cdn.com/v4/letter/d/45deac/32.png) [@Dunken](https://discourse.nodered.org/u/Dunken)
#### Post date: [11 October 2023 05:20 UTC](https://discourse.nodered.org/t/create-flows-json-programmatically/81934/5 "2023-10-11T05:20:20Z")

</div>

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

---

<div class="post-metadata">

### Author: ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)
#### Post date: [11 October 2023 07:01 UTC](https://discourse.nodered.org/t/create-flows-json-programmatically/81934/6 "2023-10-11T07:01:57Z")

</div>

> [@Dunken](#):
>
> call GET /flow/:id for the flows needed in the new file and manually create a new file of the the results

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.

---

<div class="post-metadata">

### Author: ![Dunken](https://avatars.discourse-cdn.com/v4/letter/d/45deac/32.png) [@Dunken](https://discourse.nodered.org/u/Dunken)
#### Post date: [11 October 2023 07:30 UTC](https://discourse.nodered.org/t/create-flows-json-programmatically/81934/7 "2023-10-11T07:30:03Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [10 December 2023 07:30 UTC](https://discourse.nodered.org/t/create-flows-json-programmatically/81934/8 "2023-12-10T07:30:30Z")

</div>

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