# Clone/share a "modular" subflow

**URL:** https://discourse.nodered.org/t/clone-share-a-modular-subflow/22145
**Category:** General
**Created:** [23 February 2020 14:10 UTC](https://discourse.nodered.org/t/clone-share-a-modular-subflow/22145 "2020-02-23T14:10:02Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![alexk111](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/alexk111/32/16891_2.png) [@alexk111](https://discourse.nodered.org/u/alexk111)
#### Post date: [23 February 2020 14:10 UTC](https://discourse.nodered.org/t/clone-share-a-modular-subflow/22145/1 "2020-02-23T14:10:02Z")

</div>

Is there a way to clone a subflow depending on other subflows, without making clones of the deps?

---

<div class="post-metadata">

### Author: ![alexk111](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/alexk111/32/16891_2.png) [@alexk111](https://discourse.nodered.org/u/alexk111)
#### Post date: [23 February 2020 17:08 UTC](https://discourse.nodered.org/t/clone-share-a-modular-subflow/22145/2 "2020-02-23T17:08:30Z")

</div>

In case someone needs it, here is how I could clone the subflow without cloning nested subflows:

1. Select an instance of the subflow
2. Export it
3. In the exported JSON array remove all node definitions, excluding the one describing the subflow to clone
4. Clear the `in.wires` and `out.wires` arrays
5. Import the code. This will create a copy of the subflow without nodes content.
6. Copy/paste the nodes from the original subflow to the cloned one and connect the in/out nodes

It requires some manual work, but still much faster than recreating long lists of env variables.

---

<div class="post-metadata">

### Author: ![alexk111](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/alexk111/32/16891_2.png) [@alexk111](https://discourse.nodered.org/u/alexk111)
#### Post date: [23 February 2020 17:39 UTC](https://discourse.nodered.org/t/clone-share-a-modular-subflow/22145/3 "2020-02-23T17:39:54Z")

</div>

At the moment it seems impossible to import a node/flow without cloning nested subflows that already exist. Are there any plans on this in Node Red? This will greatly improve flow sharing. If there isn't a way to make the same subflow detection algorithm covering 100% cases, then maybe show a dialog window asking to either create a subflow or use an existing one, pre-selecting the ones looking the same.

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [23 February 2020 18:00 UTC](https://discourse.nodered.org/t/clone-share-a-modular-subflow/22145/4 "2020-02-23T18:00:07Z")

</div>

already this item on the whiteboard/backlog - [https://trello.com/c/JaBxKZfB/56-subflows-when-importing-existing-subflow-with-changes-offer-to-update-or-clone](https://trello.com/c/JaBxKZfB/56-subflows-when-importing-existing-subflow-with-changes-offer-to-update-or-clone)

---

<div class="post-metadata">

### Author: ![alexk111](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/alexk111/32/16891_2.png) [@alexk111](https://discourse.nodered.org/u/alexk111)
#### Post date: [23 February 2020 18:11 UTC](https://discourse.nodered.org/t/clone-share-a-modular-subflow/22145/5 "2020-02-23T18:11:24Z")

</div>

> When importing existing subflow with changes, offer to update or clone

Does the item cover subflows without changes (offer to use existing one or clone)?

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [23 February 2020 18:51 UTC](https://discourse.nodered.org/t/clone-share-a-modular-subflow/22145/6 "2020-02-23T18:51:18Z")

</div>

Maybe. At the moment it's an item on the backlog that hasn't had any more design work on it beyond writing what you've read.

---

<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: [23 April 2020 18:51 UTC](https://discourse.nodered.org/t/clone-share-a-modular-subflow/22145/7 "2020-04-23T18:51:26Z")

</div>

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