일. 8월 17th, 2025

G: Hey n8n Automators! 👋 Are you tired of messy data holding back your workflows? Do you spend countless hours trying to reshape information to fit your needs? If so, you’ve landed on the right page!

In the world of automation, data is king 👑, but raw data is rarely in the perfect format. That’s where n8n, the powerful low-code automation platform, and its unsung hero, the Set Node, come into play! The Set Node is an absolute workhorse for data transformation, allowing you to add, modify, rename, and remove fields with incredible precision.

This masterclass isn’t just theory. We’re diving deep into 10 practical, real-world examples that will empower you to become a Set Node maestro. Get ready to clean, enrich, and perfectly tailor your data for any workflow! Let’s get started! 🚀


🔍 What Exactly is the n8n Set Node?

At its core, the n8n Set Node is your go-to tool for manipulating the data that flows through your workflow items. Think of it as a data sculptor 👨‍🎨, giving you the power to:

  • Add New Fields: Introduce completely new pieces of information to your data.
  • Modify Existing Fields: Change the value of an existing field.
  • Rename Fields: Give an existing field a new name.
  • Remove Fields: Get rid of unnecessary or sensitive information.

Why is it so crucial? 🤔 Because data from one source rarely perfectly matches the requirements of another. The Set Node acts as a bridge, ensuring your data is always in the right shape for the next step in your automation journey, whether it’s sending an email, updating a database, or posting to a social media channel.


🚀 Getting Started with the Set Node

Adding a Set Node to your workflow is as simple as searching for “Set” in the node picker. Once added, you’ll primarily interact with three sections:

  1. Values to Set: This is where the magic happens! You define new fields or modify existing ones using expressions.
  2. Rename: A dedicated section for changing field names.
  3. Remove: A straightforward way to delete fields.

A quick note on Expressions: n8n uses a powerful expression language, typically enclosed in double curly braces {{ }}. This allows you to reference data from previous nodes ($json.fieldName), use JavaScript-like logic, and perform complex calculations. Don’t worry, we’ll see plenty of examples!


🎯 10 Practical Set Node Examples

Let’s get our hands dirty with some real-world scenarios! For each example, we’ll show you:

  • The Goal 🎯
  • The Input Data 📥
  • The Set Node Configuration ⚙️
  • The Output Data 📤
  • A clear Explanation 💡

Example 1: Adding a New Static Field

Goal: Add a fixed status field to all incoming items. Scenario: You’re processing new user sign-ups and want to mark them all as “Pending Approval” initially.

Input Data:

[
  {
    "name": "Alice Wonderland",
    "email": "alice@example.com"
  },
  {
    "name": "Bob The Builder",
    "email": "bob@example.com"
  }
]

Set Node Configuration:

  • Values to Set:
    • Name: status
    • Value: Pending Approval (Type: String)

Output Data:

[
  {
    "name": "Alice Wonderland",
    "email": "alice@example.com",
    "status": "Pending Approval"
  },
  {
    "name": "Bob The Builder",
    "email": "bob@example.com",
    "status": "Pending Approval"
  }
]

Explanation: This is the simplest use case. You’re just injecting a static piece of information into every item that passes through. Useful for default values or tagging.


Example 2: Adding a New Dynamic Field (Concatenation)

Goal: Combine existing fields to create a new, more comprehensive field. Scenario: You have separate firstName and lastName fields but need a fullName field for an external system.

Input Data:

[
  {
    "firstName": "John",
    "lastName": "Doe"
  },
  {
    "firstName": "Jane",
    "lastName": "Smith"
  }
]

Set Node Configuration:

  • Values to Set:
    • Name: fullName
    • Value: {{ $json.firstName + ' ' + $json.lastName }} (Type: String – Expression)

Output Data:

[
  {
    "firstName": "John",
    "lastName": "Doe",
    "fullName": "John Doe"
  },
  {
    "firstName": "Jane",
    "lastName": "Smith",
    "fullName": "Jane Smith"
  }
]

Explanation: We’re using an expression to dynamically pull values from $json.firstName and $json.lastName and combine them with a space in between. Expressions are incredibly powerful! 💪


Example 3: Modifying an Existing Field’s Value

Goal: Update a numerical value based on a calculation. Scenario: You receive product prices without tax, and you need to add a 5% tax to them.

Input Data:

[
  {
    "product": "Widget A",
    "price": 100
  },
  {
    "product": "Gadget B",
    "price": 250
  }
]

Set Node Configuration:

  • Values to Set:
    • Name: price (Important: Use the same field name to modify it!)
    • Value: {{ $json.price * 1.05 }} (Type: Number – Expression)

Output Data:

[
  {
    "product": "Widget A",
    "price": 105
  },
  {
    "product": "Gadget B",
    "price": 262.5
  }
]

Explanation: By setting a value to an existing field name, you overwrite its current value. Here, we perform a simple multiplication to calculate the price including tax.


Example 4: Conditional Logic (Ternary Operator)

Goal: Set a field’s value based on a condition. Scenario: You want to categorize orders as “High Value” or “Standard Value” based on their total amount.

Input Data:

[
  {
    "orderId": "ORD-001",
    "amount": 120
  },
  {
    "orderId": "ORD-002",
    "amount": 75
  }
]

Set Node Configuration:

  • Values to Set:
    • Name: orderCategory
    • Value: {{ $json.amount > 100 ? "High Value" : "Standard Value" }} (Type: String – Expression)

Output Data:

[
  {
    "orderId": "ORD-001",
    "amount": 120,
    "orderCategory": "High Value"
  },
  {
    "orderId": "ORD-002",
    "amount": 75,
    "orderCategory": "Standard Value"
  }
]

Explanation: We use a ternary operator (condition ? valueIfTrue : valueIfFalse) within the expression to apply conditional logic. This is incredibly useful for mapping statuses or creating flags. 🚩


Example 5: Renaming a Field

Goal: Change the name of an existing field. Scenario: An upstream system calls a field emailAddress, but your downstream CRM expects it to be customerEmail.

Input Data:

[
  {
    "id": 101,
    "emailAddress": "user1@example.com"
  },
  {
    "id": 102,
    "emailAddress": "user2@example.com"
  }
]

Set Node Configuration:

  • Rename Section:
    • Old Name: emailAddress
    • New Name: customerEmail

Output Data:

[
  {
    "id": 101,
    "customerEmail": "user1@example.com"
  },
  {
    "id": 102,
    "customerEmail": "user2@example.com"
  }
]

Explanation: The “Rename” section is specifically designed for this purpose, making it cleaner than trying to achieve it with expressions. It effectively re-labels the key in your JSON object.


Example 6: Removing Fields

Goal: Delete unwanted or sensitive fields from your data. Scenario: You’ve received data with a passwordHash field that you need to remove before sending it to a less secure system.

Input Data:

[
  {
    "userId": "U001",
    "name": "Alex",
    "email": "alex@example.com",
    "passwordHash": "xyz123abc"
  },
  {
    "userId": "U002",
    "name": "Blake",
    "email": "blake@example.com",
    "passwordHash": "def456ghi"
  }
]

Set Node Configuration:

  • Remove Section:
    • Field to Remove: passwordHash (click “Add Field” and type the name)

Output Data:

[
  {
    "userId": "U001",
    "name": "Alex",
    "email": "alex@example.com"
  },
  {
    "userId": "U002",
    "name": "Blake",
    "email": "blake@example.com"
  }
]

Explanation: Use the “Remove” section to specify which fields should be completely purged from your data items. Great for data privacy and cleaning up unnecessary clutter. 🧹


Example 7: Extracting Part of a String (e.g., File Extension)

Goal: Extract a specific piece of information from a string. Scenario: You have a fileName and want to extract just the extension.

Input Data:

[
  {
    "id": "doc1",
    "fileName": "report.2023.pdf"
  },
  {
    "id": "img2",
    "fileName": "holiday_photo.jpg"
  }
]

Set Node Configuration:

  • Values to Set:
    • Name: extension
    • Value: {{ $json.fileName.split('.').pop() }} (Type: String – Expression)

Output Data:

[
  {
    "id": "doc1",
    "fileName": "report.2023.pdf",
    "extension": "pdf"
  },
  {
    "id": "img2",
    "fileName": "holiday_photo.jpg",
    "extension": "jpg"
  }
]
]

Explanation: We’re using JavaScript string methods: split('.') to turn the filename into an array of parts separated by dots, and pop() to get the last element (which should be the extension).


Example 8: Duplicating a Field

Goal: Create a new field with the exact same value as an existing one. Scenario: You have a productId and need a sku field with the same value for a different system.

Input Data:

[
  {
    "item": "T-Shirt",
    "productId": "TSHIRT-RED-M"
  },
  {
    "item": "Jeans",
    "productId": "JEANS-BLUE-L"
  }
]

Set Node Configuration:

  • Values to Set:
    • Name: sku
    • Value: {{ $json.productId }} (Type: String – Expression)

Output Data:

[
  {
    "item": "T-Shirt",
    "productId": "TSHIRT-RED-M",
    "sku": "TSHIRT-RED-M"
  },
  {
    "item": "Jeans",
    "productId": "JEANS-BLUE-L",
    "sku": "JEANS-BLUE-L"
  }
]

Explanation: Simply referencing an existing field’s value in a new field’s expression effectively duplicates it. Useful when different systems use different names for the same identifier.


Example 9: Handling Missing Data / Default Values

Goal: Provide a default value for a field if it’s missing or empty. Scenario: You receive user data, but the phone field is sometimes null or empty. You want to set it to “N/A” if that’s the case.

Input Data:

[
  {
    "name": "Charlie",
    "email": "charlie@example.com",
    "phone": "123-456-7890"
  },
  {
    "name": "Dana",
    "email": "dana@example.com",
    "phone": null
  },
  {
    "name": "Eve",
    "email": "eve@example.com",
    "phone": ""
  }
]

Set Node Configuration:

  • Values to Set:
    • Name: contactPhone
    • Value: {{ $json.phone || "N/A" }} (Type: String – Expression)

Output Data:

[
  {
    "name": "Charlie",
    "email": "charlie@example.com",
    "phone": "123-456-7890",
    "contactPhone": "123-456-7890"
  },
  {
    "name": "Dana",
    "email": "dana@example.com",
    "phone": null,
    "contactPhone": "N/A"
  },
  {
    "name": "Eve",
    "email": "eve@example.com",
    "phone": "",
    "contactPhone": "N/A"
  }
]

Explanation: The || (logical OR) operator in JavaScript expressions is perfect for this. If $json.phone has a “truthy” value (not null, undefined, 0, false, or empty string), it uses that. Otherwise, it falls back to “N/A”.


Example 10: Transforming Boolean/Status Values to Human-Readable Text

Goal: Convert a boolean true/false or other internal status into a descriptive string. Scenario: Your database stores is_active as a boolean, but your notification system needs “Active” or “Inactive”.

Input Data:

[
  {
    "user_id": "U003",
    "is_active": true
  },
  {
    "user_id": "U004",
    "is_active": false
  }
]

Set Node Configuration:

  • Values to Set:
    • Name: accountStatus
    • Value: {{ $json.is_active ? "Active" : "Inactive" }} (Type: String – Expression)

Output Data:

[
  {
    "user_id": "U003",
    "is_active": true,
    "accountStatus": "Active"
  },
  {
    "user_id": "U004",
    "is_active": false,
    "accountStatus": "Inactive"
  }
]

Explanation: Another excellent use case for the ternary operator! This transforms a simple boolean into a more user-friendly string representation, perfect for reports or user-facing messages.


🧠 Advanced Tips for Set Node Mastery

  • Chaining Set Nodes: Don’t be afraid to use multiple Set Nodes in sequence! Sometimes it’s cleaner to perform several small transformations rather than one giant, complex expression.
  • Context Awareness: Remember that expressions in a Set Node can access not only $json (the current item’s data) but also $item (more detailed item info including index, binary data), $node (data from other nodes), and even $env (environment variables).
  • Regular Expressions (Regex): For complex string parsing (like extracting specific patterns from text), learn the basics of regular expressions. They are incredibly powerful when combined with JavaScript string methods like .match(), .replace(), or .test().
  • Debugging: If your Set Node isn’t behaving as expected, use a “NoOp” or “Logger” node immediately after it to inspect the output. This helps you see exactly what data is being produced.

🌟 Conclusion

The n8n Set Node might seem simple at first glance, but as you’ve seen, its power lies in its versatility and the ability to leverage n8n’s expression language. By mastering these 10 practical examples, you’re well on your way to becoming an n8n data transformation expert! 🧙‍♂️

Clean, well-structured data is the backbone of any robust automation. By using the Set Node effectively, you’ll streamline your workflows, reduce errors, and unlock new possibilities for integrating disparate systems.

So, go forth and experiment! Play with different expressions, combine the techniques, and watch your n8n workflows transform from functional to phenomenal. Happy automating! ✨

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다