node-red-contrib-string 0.2.0

Provides a string manipulation node with a chainable UI based on the concise and lightweight

npm install node-red-contrib-string

Provides a node with native and extended chainable JavaScript string parsing and manipulation methods. The node is a high level wrapper for the concise and lightweight object and uses Node-RED's editor UI to create easy chaining. Additional string parsing functionality and compatibility have been added from the fork.

Applies string methods from a given context property and assigns the results optionally to the same or another context property. Methods can be chained by adding multiple methods sequentially and with parameters that are literal or from other context properties. The string object always passes along the msg object with (if any) changes applied.

By default, string "from" and "to" apply to the msg.payload property but may be set to any property of global, flow, or msg contexts.


Data Extraction - Get Technical FAX

Methods can be chained within the UI enabling complex and versatile parsing functionality. Here we can see how easy it is to extract the technical FAX phone number WhoIS information:

Node-RED Example

Consider the given WhoIS dump from a command line console (see image below). We will want to obtain the FAX number (outlined in the dashed yellow). The string node will extract the technical FAX phone number by first removing the header, followed by all data up to the phrase "Technical:". This ensures that we don't accidentally obtain a FAX number from another section. Lastly, the string node grabs the number from between the markers "Fax:" and a carriage return and displays the output in the Node-RED debug window.

WhoIS Commandline Dump

The extraction is performed using JavaScript's unique ability to chain actions on a given object such as the native String object or the popular jQuery component. This unique contribution to Node-RED furnishes a lightweight and enhanced version of string parsing functions. The visual representation in the first image could be coded by hand in JavaScript (after including all the dependencies) as:

             .between('FAX:', '\n')

Validate Phone Number

Furthermore, a single string node could have the properties set to perform data validation. In this simple example we'll perform some conditional checks to see if the phone number is numeric and furnish a friendly error message if it is not. Consider the following flow:

Validate Phone Number

Let's take a look at the string node titled "Verify Number" (see image below). The properties for the node have been configured to use the methods stripPunctuation and isNumeric which will result in a boolean true or false. Next, we convert the boolean to a string using toString. Lastly, we use the replaceAll methods to convert the only two boolean possibilities to the original number as found in property msg.payload or the informative error message "Error! Not a valid number.".

Verify Number Node


Run the following command in your Node-RED user directory (typically ~/.node-red):

npm install node-red-contrib-string

The string node will appear in the palette under the function group.

Node Info

Version: 0.2.0
Updated 2 days ago
License: MIT


146 in the last day
899 in the last week
2671 in the last month


  • string


  • node-red
  • string
  • strings
  • stringjs
  • string.js
  • parsing


  • steveorevo