Introduction
The Set node is your primary tool for reshaping data as it flows through n8n workflows. Unlike nodes that fetch external data, Set focuses entirely on transforming what you already have: adding new fields, overwriting existing ones, or removing fields you don't need. This makes it essential for preparing payloads before sending them to APIs, databases, or other services.
Every item in n8n is a JSON object. The Set node lets you define exactly which fields each item should contain and what values they should hold. You can hardcode values, copy data from other fields, or use expressions to calculate new values based on upstream data.
Basic Field Operations
The Set node operates in one of two modes: Keep Only Set (replaces the entire item with only the fields you define) or Add/Overwrite (merges your new fields into the existing item). For most transformation tasks, Add/Overwrite gives you more flexibility.
To add a field, click Add Field and choose the appropriate type: String, Number, Boolean, or others. Each field requires a name and a value. The name becomes the JSON key, and the value can be static text, a number, or an expression.
Notice that the original fields remain. If you switch to Keep Only Set mode, the output would contain only id, name, and isActive.
Referencing Upstream Data with Expressions
Expressions are how you access data from previous nodes. The most common pattern is {{$json.fieldName}}, which reads a field from the current item. You can also use JavaScript inside expressions to transform values on the fly.
You can reference fields from other nodes using {{$node.NodeName.json.fieldName}}. This is useful when you need to combine data from multiple sources or compare values across workflow steps.
Removing Unwanted Fields
Sometimes you need to strip out sensitive or unnecessary fields before sending data downstream. In Keep Only Set mode, you simply define the fields you want to keep and everything else disappears. In Add/Overwrite mode, removing fields requires using the Remove Other Fields toggle or manually setting fields to null.
This approach is safer than trying to delete fields individually, especially when dealing with dynamic data structures where you might not know all field names in advance.
Common Patterns and Gotchas
When building complex transformations, work incrementally. Add one or two fields, execute the node, and verify the output before adding more. This makes debugging much easier than configuring ten fields at once and troubleshooting errors.
Expression errors are common. If an expression fails to evaluate, n8n usually leaves the field empty or shows an error badge. Double-check your syntax: expressions must be wrapped in double curly braces, and JavaScript code inside must be valid. Use the Expression Editor panel to test expressions before committing them.
Type mismatches can cause downstream issues. If a field expects a number but receives a string, explicitly convert it using Number or parseInt inside your expression. Similarly, use String to convert numbers to text when needed.
The Set node processes each item independently. If you have 50 items entering the node, each one gets transformed according to your field definitions. This means expressions like {{$json.fieldName}} always refer to the current item being processed, not the entire array.
Summary
The Set node is your scalpel for data transformation in n8n. Use Add/Overwrite mode when you want to augment existing data, and Keep Only Set when you need to create a clean slate with only specific fields. Expressions let you reference data from anywhere in your workflow and apply JavaScript transformations inline. Master the Set node and you'll spend less time wrestling with data formats and more time building functional workflows.
Lesson Checkpoint
Review what you learned and get feedback on your work.