How to Copy and Export Nodes and Flows in Node-Red

There a several ways that you can copy nodes and flows between flows in the node-red Workspace.

They are:

  • Select, Copy and Paste
  • Export and Import Clipboard
  • Save To and Retrieve from the Local Library





Copy and Paste

This works just like copying text in a word processor. You simply select the nodes you want using the CTRL key to select individual nodes together into a group or CTRL+A to select all nodes in the workspace.

Then use CTRL+C to Copy.

You then move to the place on the workspace or open the workspace where you want to copy the nodes to and use CTRL+V to paste the nodes/flow into the workspace..

Using Export and Import and The Clipboard

This method can be used for exchanging flows between systems as well as on the same system.

To do this you need to highlight each node in the flow and then click on Menu>export>clipboard.

Note: Use CTRL+A to select all nodes in the workspace.

export-node-flow

The contents of the export file will be displayed click on export to clipboard.

node-export-to-clipboard

You then need to open a file editor and paste the contents into the file using CTRL+V.

Give the file a name and save it.

Importing A Flow

You will need to open the flow in a text editor, and then copy its contents using CRTL+C.

You then go to Menu>import>clipboard and paste the file into the window and click the import button to complete the import.

node-red-import-flows

Using The Library

If you want to save a flow or function and reuse it in another flow  then you can save it to the local library.

To save a flow to the library highlight all nodes in the flow by using CTRL+A then use the main menu (top right) and select Export>Library.

node-red-export-flow-library

 

You will need to give the flow a name and optionally you can create a folder for the flow.

For example you could store flows in the flows folder and functions in the functions folder.

All flows are stored in the lib folder under the users .node-red folder.

To save a function to the library double click on the function to edit it and click on the bookmark icon next to the function name.

A drop down menu appears to either import or save the function to the library.

node-red-function-library

You need to give the file a name and optionally a folder to store it in.

node-red-save-function-library-1

Note: The function itself should have a name as you will need this when importing the function.

node-function-name

If you don’t give the function a name it appears as an unnamed function when importing.

Using Library Functions and Flows

To use a library flow use the Import>Library option and select the flow, and it appears in the flow canvas

To use a library function drag a function node into the flow canvas then open it for editing.

Click on the bookmark icon next to the function name and select open library from the drop down menu.

Open folder containing functions and the functions appear by name. Select the function and click load, to load the library code into the function.

node-red-load-function-code

Common Questions and Answers

Q -Can’t I just export the flow to the clipboard and copy it to a text file?

A- Yes but it isn’t as convenient as using libraries

Q- Can I use libraries to copy flows between computers?

A- Yes but it isn’t as easy as using the export clipboard option?

Q- Can I share my library files with others.?

A- Yes you would need to copy the lib folder which is under your .node-red folder.

==> How to create a Basic Dashboard

Related Tutorials and Resources:

Facebooktwittergoogle_plusredditpinterestlinkedinmail

4 comments

    1. I assume you mean the code for the actual nodes.
      Not as far as I a aware. Is there a reason why you need it?
      rgds
      steve

  1. Hi Steve,

    Nice tutorial – thanks!
    A quick question/scenario:
    – Given that I have a few small (pi-driven) node-red instances out in the wild – all having the same set of flows.
    – And I periodically may need to update these flows (correct errors, improve functionality etc).
    – Is there a way to automate this process and do it OTA? For example have a node-red flow check for updates and then update other flows as required.

    Hope I’m making sense.
    Thanks.

Leave a Reply

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