# Work with text, numbers and logic nodes

> A guided map of Nodespell's data and logic nodes for text, numbers, arrays, objects and JSON, math, conditions and loops, with worked examples.

Source: https://docs.nodespell.com/graph/data-and-logic/ · Last updated: 2026-11-10

Data and logic nodes in Nodespell work with values instead of media: text, numbers, true/false values, lists (arrays) and key-value objects. Use them to build prompts from parts, calculate parameter values, choose between inputs, and repeat work for every item in a list. They run in your browser and never use [credits](https://docs.nodespell.com/account/plans-and-credits/).

Add any of them with the [Tab menu](https://docs.nodespell.com/graph/add-nodes/) by typing the label shown below, or browse them in the [Node Browser](https://docs.nodespell.com/graph/add-nodes/). The output of a data node connects to any compatible input or [parameter](https://docs.nodespell.com/graph/parameters/), including a model's prompt.

## Text nodes

| Node                                                         | Use it to                                                                                    |
| ------------------------------------------------------------ | -------------------------------------------------------------------------------------------- |
| **String Template**                                          | Fill a template such as `A photo of ${0} at ${1}` with the strings connected to **Strings**. |
| **String Concat**                                            | Join several strings, with an optional **Prefix**, **Separator** and **Suffix**.             |
| **String Replace**                                           | Replace text; wrap the search in `/…/` to use a regular expression.                          |
| **String Split**                                             | Split text into an array at a **Separator**.                                                 |
| **String Case**                                              | Change case, for example **Upper Case**, **Sentence Case** or **Kebab Case**.                |
| **String Trim**, **String Pad**, **String Slice**            | Clean up, pad or cut text.                                                                   |
| **String Length**, **String Includes**, **String Ends With** | Measure or test text.                                                                        |

## Number and math nodes

| Node                                                                          | Use it to                                                            |
| ----------------------------------------------------------------------------- | -------------------------------------------------------------------- |
| **Plus**, **Minus**, **Multiply**, **Divide**, **Remainder**, **Exponent**    | Basic arithmetic on **First** and **Second**.                        |
| **Remap**                                                                     | Map a value from one range to another, for example 0–1 to 0–100.     |
| **Clamp**                                                                     | Keep a value between **Min** and **Max**.                            |
| **Round**, **Floor**, **Ceiling**, **Truncate**                               | Turn a number into a whole number.                                   |
| **Random**                                                                    | Return a number between 0 and 1; set **Seed** to make it repeatable. |
| **Noise**                                                                     | Return a smooth noise value between 0 and 1.                         |
| **Minimum**, **Maximum**, **Absolute**, **Negate**, **Sign**, **Square Root** | Other common operations.                                             |
| **Is Finite**, **Is Integer**, **Is NaN**                                     | Test a number.                                                       |

## List (array) nodes

| Node                                                                                  | Use it to                                                    |
| ------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
| **Merge As Array**                                                                    | Collect several values into one array.                       |
| **Array Get Element**                                                                 | Read one item by index (0 is the first).                     |
| **Array Length**                                                                      | Count the items.                                             |
| **Array Range**                                                                       | Make a sequence of numbers, such as 0 to 10 in steps of 0.5. |
| **Array Slice**, **Array Take**                                                       | Keep part of an array.                                       |
| **Array Filter**, **Array Deduplicate**                                               | Remove empty, unwanted or repeated items.                    |
| **Array Sort**, **Array Reverse**, **Array Shuffle**                                  | Reorder items; **Array Shuffle** accepts a seed.             |
| **Array Append**, **Array Insert Item**, **Array Remove Item**, **Array Set Element** | Edit items.                                                  |
| **Array Concat**, **Array Flatten**, **Array Chunk**, **Array Zip**, **Repeat**       | Combine, flatten, split or repeat arrays.                    |

## Object and JSON nodes

| Node                                                                                                  | Use it to                                                                 |
| ----------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| **JSON Parse**                                                                                        | Turn JSON text, such as a text model's structured answer, into an object. |
| **JSON Stringify**                                                                                    | Turn an object back into text.                                            |
| **Object Get Key**                                                                                    | Read one value by its key.                                                |
| **Create Object**, **Key Value Pair**                                                                 | Build an object.                                                          |
| **Object Add Key**, **Object Delete Key**, **Object Rename Key**, **Object Merge**, **Object Filter** | Edit an object.                                                           |
| **Object Entries**, **Object From Entries**, **Array Zip Object**                                     | Convert between objects and arrays.                                       |

## Logic, flow control and conversion nodes

| Node                                                                                                      | Use it to                                                                                        |
| --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
| **If Else**                                                                                               | Output **True Value** or **False Value** depending on **Condition**.                             |
| **Compare**                                                                                               | Compare two numbers with **Equal**, **Less Than**, **Greater Than** and similar operations.      |
| **String Compare**                                                                                        | Compare two strings, optionally ignoring case or whitespace.                                     |
| **Gate**                                                                                                  | Combine two true/false values with **AND**, **OR**, **XOR**, **NOT** and others.                 |
| **Switch Input**                                                                                          | Pass through one of several connected inputs, chosen by its index in **Which** (0 is the first). |
| **Is Falsy**, **Is Nullish**                                                                              | Test whether a value is empty or missing.                                                        |
| **Map Container**                                                                                         | Run the nodes inside it once for every item in an array.                                         |
| **String To Float**, **String To Int**, **To String**, **To Fixed**, **To Precision**, **To Exponential** | Convert between text and numbers.                                                                |
| **Constant**                                                                                              | Hold a fixed **String**, **Number** or **Boolean** value.                                        |
| **Reference**                                                                                             | Read another node's output without a connection.                                                 |
| **Type Of**                                                                                               | Report the type of a value.                                                                      |
| **Dot**, **No Operation**                                                                                 | Pass a value through unchanged to tidy connections.                                              |

## Example: build a prompt from a template

1. Add two **Constant** nodes with **Value Type** set to **String**, for example `a red bicycle` and `golden hour`.
2. Add a **String Template** node and set **Template String** to `Product photo of ${0}, lit at ${1}`.
3. Connect both constants to its **Strings** input, in order. The first connection fills `${0}`, the second `${1}`.
4. Connect the template's **Value** output to the prompt input of an image model and run it.

Change either constant and run again to try a new subject or light without retyping the prompt. For writing longer prompts by hand, see [Prompts and saved text](https://docs.nodespell.com/graph/prompts-and-saved-text/).

## Example: repeat work for every item in a list

1. Add a **Constant** with the text `cat, dog, fox` and connect it to a **String Split** node with **Separator** set to `, `.
2. Add a **Map Container** and connect the split **Output** to its **Items** input.
3. Select the Map Container and press `Enter` to go inside.
4. Add a **Map Item** node (the current item), connect it to a **String Case** node set to **Upper Case**, and connect that to a **Map Output** node.
5. Press `U` to go back out, select the Map Container, and run it.

The **Values** output returns the results in the original order: `CAT`, `DOG`, `FOX`. Inside the container, **Map Index** gives the item's position and **Map Length** the total. **Max Concurrency** (default 4, up to 16) sets how many items run at once. Right-click the container and choose **Inspect Map Runs** to see each item's result.

> **Note:** Run the Map Container itself. Running a node inside it on its own shows **Run Map body node directly?**, because a direct run does not update the Map's output.

## Example: choose between two values

1. Connect a number, such as a **Random** node with a seed, to **Left** on a **Compare** node. Set **Right** to `0.5` and **Operation** to **Greater Than**.
2. Connect the **Compare** output to **Condition** on an **If Else** node.
3. Connect two prompts, one to **True Value** and one to **False Value**, and use the **If Else** output downstream.

For a fixed choice from several options, use **Switch Input** and set **Which** instead.

## Example: read a field from JSON

Connect a text model's output that contains JSON to **JSON Parse**, then connect the parsed object to **Object Get Key** and set **Key**, for example `title`. The output is that field's value, ready to use in a **String Template** or as a parameter.

## Frequently asked questions

### Do data and logic nodes cost credits?

No. They calculate in your browser and appear in run plans as free updates.

### How do I insert values into a prompt?

Use **String Template** with `${0}`, `${1}` and so on in **Template String**, and connect the values to **Strings** in order. You can also write [expressions](https://docs.nodespell.com/graph/expressions/) directly in parameters.

### How do I loop over a list in Nodespell?

Put the work inside a **Map Container**, use **Map Item** for the current item and **Map Output** for each result, and connect your array to **Items**.

### What is the difference between Constant and a typed parameter?

A **Constant** is a node whose output you can connect to many inputs, so one value can drive several nodes. A parameter value belongs to a single node.

## Related

- [Expressions](https://docs.nodespell.com/graph/expressions/): calculate parameter values inline
- [Connections](https://docs.nodespell.com/graph/connections/): which outputs fit which inputs
- [Levels and Folders](https://docs.nodespell.com/graph/levels-and-folders/): going inside nodes with `Enter` and `U`
- [Prompts and saved text](https://docs.nodespell.com/graph/prompts-and-saved-text/): the Prompt node
