# Split flows.json file for easier diffs

**URL:** <https://discourse.nodered.org/t/split-flows-json-file-for-easier-diffs/96692>\
**Category:** General\
**Created:** [21 April 2025 20:47 UTC](https://discourse.nodered.org/t/split-flows-json-file-for-easier-diffs/96692 "2025-04-21T20:47:30Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ThingsTinkerer](https://avatars.discourse-cdn.com/v4/letter/t/91b2a8/32.png) [@ThingsTinkerer](https://discourse.nodered.org/u/ThingsTinkerer)\
**Post date:** [21 April 2025 20:47 UTC](https://discourse.nodered.org/t/split-flows-json-file-for-easier-diffs/96692/1 "2025-04-21T20:47:30Z")

</div>

If you don't need version control, I can understand that having all code in one file is easier. But node red already has the git integration in projects mode. Is there any good way of splitting flows.json into individual code files? Diffs are a pain and it would be a breeze to be able to synchronize particular flows or subflows across repos if having multiple files.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [22 April 2025 06:09 UTC](https://discourse.nodered.org/t/split-flows-json-file-for-easier-diffs/96692/2 "2025-04-22T06:09:38Z")

</div>

This has been requested many times:

- [Formatted Function Node with separate JS files - #2 by knolleary](https://discourse.nodered.org/t/formatted-function-node-with-separate-js-files/1760/2)
- [Flows/\*.json instead of flows.json? - #6 by knolleary](https://discourse.nodered.org/t/flows-json-instead-of-flows-json/34043/6)
- [Function Node exported json - #2 by knolleary](https://discourse.nodered.org/t/function-node-exported-json/77124/2)

One promising (and simple) solution would be to support YAML format (as Nick says in the first link) but unfortunately, as of writing, no one has picked this up.

An option that would make diffs a _little_ easier would be to enable the `flowFilePretty` flag in settings.js. This will make JSON props much easier to compare (but function code will still be escaped unlike an equivalent YAML file format)

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [22 April 2025 06:29 UTC](https://discourse.nodered.org/t/split-flows-json-file-for-easier-diffs/96692/3 "2025-04-22T06:29:00Z")

</div>

I once created a visual comparison between a flow in the flow editor and the flow on the server --\> [node-red-contrib-flowcompare (node) - Node-RED](https://flows.nodered.org/node/@gregoriusrippenstein/node-red-contrib-flowcompare)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [22 April 2025 09:51 UTC](https://discourse.nodered.org/t/split-flows-json-file-for-easier-diffs/96692/4 "2025-04-22T09:51:08Z")

</div>

This doesn't help with diffing mods to the flow itself, but for mods within function nodes I use `flowFilePretty` and before committing to git I run a batch file containing:

```auto
#!/usr/bin/env sh

# generates formatted versions of node red flow files matching flow*.json
# in files flow*.json.formatted

# NOTE must have flowFilePretty: true in settings.js

for f in *flow*.json; do
  echo $f
  sed -r 's/\\n/\n/g' "$f" > "$f.formatted"
done
# remove any cred files converted
rm *_cred.json.formatted

```

This escapes function nodes in flows files, generating `flows.json.formatted` files. I include the formatted file in the git repo and a diff on that file shows the changes to the function nodes in an understandable format.

---

<div class="post-metadata">

**Author:** ![ThingsTinkerer](https://avatars.discourse-cdn.com/v4/letter/t/91b2a8/32.png) [@ThingsTinkerer](https://discourse.nodered.org/u/ThingsTinkerer)\
**Post date:** [22 April 2025 12:07 UTC](https://discourse.nodered.org/t/split-flows-json-file-for-easier-diffs/96692/5 "2025-04-22T12:07:13Z")

</div>

Some nice workarounds and hacks, also found some interesting community packages that could help. But nothing would beat a native built-in solution.

While I'm dreaming, first-class support for typescript? 😂

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [22 April 2025 15:15 UTC](https://discourse.nodered.org/t/split-flows-json-file-for-easier-diffs/96692/6 "2025-04-22T15:15:10Z")

</div>

> [@Colin](#):
>
> This doesn't help with diffing mods to the flow itself,

This the purpose of [flowhub.org](http://flowhub.org) - visual versioning of flows.

> [@ThingsTinkerer](#):
>
> But nothing would beat a native built-in solution.

Yep that's why there is a text-based, attribute by attribute diff built in to NodeRED.

---

<div class="post-metadata">

**Author:** ![ThingsTinkerer](https://avatars.discourse-cdn.com/v4/letter/t/91b2a8/32.png) [@ThingsTinkerer](https://discourse.nodered.org/u/ThingsTinkerer)\
**Post date:** [22 April 2025 17:31 UTC](https://discourse.nodered.org/t/split-flows-json-file-for-easier-diffs/96692/7 "2025-04-22T17:31:10Z")

</div>

If flows.json was split, I could simply distribute a new version of a subflow by copying its file. At the moment distributing subflow version has become very difficult.

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [22 April 2025 17:41 UTC](https://discourse.nodered.org/t/split-flows-json-file-for-easier-diffs/96692/8 "2025-04-22T17:41:03Z")

</div>

> [@ThingsTinkerer](#):
>
> particular flows or subflows across repos if having multiple files.

that's what [flowhub.org](http://flowhub.org) does or helps with - since [flowhub.org](http://flowhub.org) works at the level of flow _tabs_ not flows.json. So you create your flows.json using various flow tabs and each flow tab is hosted flowhub (i.e. in a github repo) and then you combine you individual flows into one large flows.json.

---

<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:** [21 July 2025 17:41 UTC](https://discourse.nodered.org/t/split-flows-json-file-for-easier-diffs/96692/9 "2025-07-21T17:41:23Z")

</div>

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