How To: NodeRed – Import and Export Node Code

Another great feature of NodeRed is that the complete – or even individual parts of the configuration – can be exported formatted as a JSON string.

JSON strings are strings in which configurations are formatted according to a specific pattern. But what makes handling so easy: These are simple text characters that you just have to copy and paste to transfer them from one system to the other.
So if you have a cool configuration put together and want to share it with your buddy you can send him the configuration in a simple e-mail.

I call this configuration “Node Code” in this and other articles. Usually (on other pages and also on the NodeRed page itself) this is called “flow”, but I think then the demarcation to many other functions in NodeRed is not so clear. For example, the tabs in the NodeRed configuration interface are also called “flows.”
Besides, Node code sounds kinda cool too. 🙂

Well, long story short, how your Node configurations are exported and imported is described in the following article.

Hints for our lovely english readers: Basically, many of the articles on Nerdiy.de are translations from the original german articles. Therefore, it may happen here and there that some illustrations are not available in english and that some translations are weird/strange/full of mistakes or generally totaly wrong. So if you find some obvious (or also not obvious) mistakes don't hesitate to leave us a hint about that in the comment section. 
Also please don't get confused, that instead of a "dot" often a "comma" is used as decimal separator. 🙂


Safety instructions

I know the following hints are always a bit annoying and seem unnecessary. But unfortunately, many people who knew it "better" from carelessness lost their eyes, fingers or other things or hurt themselves. In comparison, a loss of data is almost not worth mentioning, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Even the coolest project is worth no injury or other annoyance. https://www.nerdiy.de/sicherheitshinweise/


Requirements

Helpful Articles:
NodeRed should of course already be installed so that you can install new nodes.
How to prepare a RaspberryPi and then NodeRed installed on it is described in the following articles.

The following articles describe what to do to prepare the RaspberryPi:
RaspberryPi – Setting up for Nerdiys!
RaspberryPi – The first configuration
RaspberryPi – Controlling the RaspberryPi via SSH
NodeRed – Installing NodeRed on the RaspberryPi

Required tools:
-none-

Required material:

In the following list you will find all the parts you need to implement this article.


Log in to the NodeRed configuration interface

Before you can edit your NodeRed configuration you must - if activated - first log in to the NodeRed configuration interface.

View of the login screen. Here you have to enter the login details that you entered during the configuration of the login. Information about this can be found in the article NodeRed - User Login Setup.

Import Node Code

The following describes how to import an existing Node code.

First click on the three gray bars in the right-top corner.
… then on Import-> Clipboard.
In the now opened window you can insert the desired Node code.
In the “Import to” section, you can then choose whether to insert the nodes in the current flow or in a new flow. After clicking on “Import”, the node code is converted into graphic nodes …
… and can be freely positioned with the mouse in the desired flow.

Export Node Code

The following describes how to export an existing NodeCode.

In order to export a certain configuration to the NodeCode you have to select the respective nodes first.
These are then outlined with a yellow/orange frame, which signals that these nodes are selected.
Now you click on the three gray bars in the right-top corner.
And then on Export-> Clipboard.
In the window that appears, you first have the option of exporting the selected nodes, all nodes of the current flow (ie the current page you are on) or all the flows you have configured , Since you have just selected nodes that you want to export, you select “selected nodes” here. In the text field underneath you can already see the JSON string which contains the configuration of the nodes. Under the text field, you can use the buttons “compact” and “formatted” to select whether you want to format the code legibly or export compact formatted. If you only want to transfer the code, “compact” is the right choice. For the actual export you click on “Export to Clipboard”. You can then insert this exported NodeCode back into other NodeRed configurations.

I hope everything worked as described. If not or you have any other questions or suggestions, please let me know in the comments. Also, ideas for new projects are always welcome. 🙂

Fab

P.S. Many of these projects - especially the hardware projects - cost a lot of time and money. Of course I do this because I enjoy it, but if you appreciate it that I share these information with you, I would be happy about a small donation to the coffee box. 🙂

Buy Me a Coffee at ko-fi.com

Leave a Reply

Your email address will not be published. Required fields are marked *