This workflow corresponds to n8n.io template #5729 — we link there as the canonical source.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"id": "1zR4oui3G7cMRnsP",
"name": "Understanding the code node",
"tags": [],
"nodes": [
{
"id": "735caeb3-82d9-4e58-aa90-d284a90a6100",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-600,
-100
],
"parameters": {
"color": 7,
"width": 460,
"height": 700,
"content": "## \ud83c\udfaf WORKFLOW PURPOSE\nThis workflow demonstrates practical Code node usage for:\n\n\u2022 **Data filtering & transformation**\n\u2022 **Statistical calculations** \n\u2022 **Formatting for external systems**\n\u2022 **Real-world business scenarios**\n\n\ud83d\udca1 Perfect for learning JavaScript data manipulation in n8n!\n\nAuthor : **David Olusola**\n\n\ud83d\ude80 **n8n Coaching**\nUnlock the full potential of n8n with personalized, one-on-one coaching. Whether you're just getting started or need help solving a specific challenge, I\u2019ll guide you step-by-step so you can build confidently and efficiently.\n\ud83d\udc49 [Book Coaching Session](mailto:david@daexai.com?subject=n8n%20Coaching%20Request)\n\n **n8n Consulting**\nHave a complex automation project, unique integration needs, or want a custom workflow built from scratch? Let\u2019s collaborate to design and implement a robust solution tailored to your business.\n\ud83d\udce9 [Inquire About Consulting Services](mailto:david@daexai.com?subject=n8n%20Consultation%20Request)\n"
},
"typeVersion": 1
},
{
"id": "69eeeaa0-490c-4cab-937c-edb266e6a0ed",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
620,
-200
],
"parameters": {
"color": 7,
"width": 680,
"height": 340,
"content": "## \ud83d\udd27 CODE NODE BASICS\n\n**Key Points:**\n\u2022 Access input data via `items[0].json`\n\u2022 Always return array of objects\n\u2022 Use `.map()` to create multiple outputs\n\u2022 Return `[{ json: data }]` format\n\n**Common Patterns:**\n```javascript\n// Single output\nreturn [{ json: result }];\n\n// Multiple outputs\nreturn array.map(item => ({ json: item }));\n```"
},
"typeVersion": 1
},
{
"id": "d7cafddc-1fb0-47c0-80a5-9584c781432d",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
680,
120
],
"parameters": {
"color": 7,
"width": 480,
"height": 180,
"content": "## \ud83d\udcca EXAMPLE 1: FILTER & TRANSFORM\n\n**What it does:**\n\u2022 Filters users over 18 years old\n\u2022 Adds calculated bonus field (10% of salary)\n\u2022 Creates formatted email addresses\n\u2022 Outputs each user as separate item\n\n**Use cases:**\n\u2022 Lead qualification\n\u2022 Customer segmentation\n\u2022 Data enrichment"
},
"typeVersion": 1
},
{
"id": "91e465df-24e5-49e9-8253-08d95c3d8860",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
680,
320
],
"parameters": {
"color": 7,
"width": 480,
"content": "## \ud83d\udcc8 EXAMPLE 2: CALCULATE STATS\n\n**What it does:**\n\u2022 Aggregates team data into statistics\n\u2022 Calculates averages, totals, distributions\n\u2022 Creates single summary object\n\n**Use cases:**\n\u2022 Dashboard data preparation\n\u2022 Report generation\n\u2022 KPI calculations\n\u2022 Business intelligence"
},
"typeVersion": 1
},
{
"id": "15f8afd0-7694-490e-909a-1cccb1aad8b6",
"name": "Sticky Note4",
"type": "n8n-nodes-base.stickyNote",
"position": [
700,
540
],
"parameters": {
"color": 7,
"width": 280,
"height": 340,
"content": "## \ud83d\udd04 EXAMPLE 3: FORMAT FOR EXPORT\n\n**What it does:**\n\u2022 Formats data for multiple output types\n\u2022 Creates CSV, email lists, API payloads\n\u2022 Adds metadata and timestamps\n\n**Use cases:**\n\u2022 API integrations\n\u2022 Email marketing prep\n\u2022 Data export functions\n\u2022 Multi-format reporting"
},
"typeVersion": 1
},
{
"id": "c56969b0-8ce9-4f12-a5ab-81571dfe5c37",
"name": "Sticky Note5",
"type": "n8n-nodes-base.stickyNote",
"position": [
-40,
-80
],
"parameters": {
"color": 7,
"width": 300,
"height": 280,
"content": "## \ud83d\ude80 QUICK START GUIDE\n\n**1. Click \"Test workflow\" to run**\n**2. Check each Code node's output**\n**3. Edit JavaScript code to experiment**\n**4. Copy patterns for your own workflows**\n\n**Pro Tips:**\n\u2022 Use `console.log()` for debugging\n\u2022 Test with small datasets first\n\u2022 Always handle edge cases\n\u2022 Return proper n8n format"
},
"typeVersion": 1
},
{
"id": "11c7822e-f7ef-4417-a489-24528b50d189",
"name": "When clicking \u2018Execute workflow\u2019",
"type": "n8n-nodes-base.manualTrigger",
"position": [
-140,
360
],
"parameters": {},
"typeVersion": 1
},
{
"id": "8e750afa-737c-4cc9-bcd6-a886e247f545",
"name": "Set Sample Data",
"type": "n8n-nodes-base.set",
"position": [
100,
340
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "99a2c0ab-5fdf-4d40-b989-492fc2393504",
"name": "scenario",
"type": "string",
"value": "user_data"
},
{
"id": "272adb73-f810-4f23-af05-f6f66fe6add8",
"name": "usersJson",
"type": "string",
"value": "[{\"name\": \"Alice Johnson\", \"age\": 28, \"email\": \"user@example.com\", \"role\": \"developer\", \"salary\": 75000}, {\"name\": \"Bob Smith\", \"age\": 17, \"email\": \"user@example.com\", \"role\": \"intern\", \"salary\": 25000}, {\"name\": \"Charlie Brown\", \"age\": 35, \"email\": \"user@example.com\", \"role\": \"manager\", \"salary\": 95000}, {\"name\": \"Diana Ross\", \"age\": 22, \"email\": \"user@example.com\", \"role\": \"designer\", \"salary\": 60000}]"
}
]
}
},
"typeVersion": 3.3
},
{
"id": "29e2b762-60ea-4262-b64b-691cafceacaa",
"name": "Code: Filter & Transform",
"type": "n8n-nodes-base.code",
"position": [
340,
160
],
"parameters": {
"jsCode": "// EXAMPLE 1: Filter adults (age > 18) and add bonus field\nconst users = JSON.parse(items[0].json.usersJson);\n\n// Filter users over 18 and add calculated bonus\nconst adults = users\n .filter(user => user.age > 18)\n .map(user => ({\n ...user,\n bonus: user.salary * 0.1, // 10% bonus\n fullEmail: `${user.name} <${user.email}>`,\n isEligible: true\n }));\n\n// Return each user as separate item for n8n\nreturn adults.map(user => ({ json: user }));"
},
"typeVersion": 2
},
{
"id": "14efb99d-7522-4c7b-bb84-4f96e67cbdba",
"name": "Code: Calculate Stats",
"type": "n8n-nodes-base.code",
"position": [
420,
440
],
"parameters": {
"jsCode": "// EXAMPLE 2: Aggregate data - calculate team statistics\nconst users = JSON.parse(items[0].json.usersJson);\n\n// Calculate team stats\nconst stats = {\n totalEmployees: users.length,\n averageAge: users.reduce((sum, user) => sum + user.age, 0) / users.length,\n totalSalary: users.reduce((sum, user) => sum + user.salary, 0),\n averageSalary: users.reduce((sum, user) => sum + user.salary, 0) / users.length,\n roleDistribution: users.reduce((acc, user) => {\n acc[user.role] = (acc[user.role] || 0) + 1;\n return acc;\n }, {}),\n minAge: Math.min(...users.map(u => u.age)),\n maxAge: Math.max(...users.map(u => u.age)),\n eligibleForBonus: users.filter(u => u.age > 18).length\n};\n\n// Return single item with all statistics\nreturn [{ json: stats }];"
},
"typeVersion": 2
},
{
"id": "f497b70c-805c-4efd-afb6-e1ec6c2adfa0",
"name": "Code: Format for Export",
"type": "n8n-nodes-base.code",
"position": [
380,
720
],
"parameters": {
"jsCode": "// EXAMPLE 3: Format data for external API or email\nconst users = JSON.parse(items[0].json.usersJson);\n\n// Create formatted output for different use cases\nconst emailList = users.map(user => user.email).join(', ');\nconst csvFormat = users.map(user => \n `${user.name},${user.age},${user.email},${user.role},${user.salary}`\n).join('\\n');\n\n// Create summary report\nconst report = {\n reportDate: new Date().toISOString(),\n teamOverview: {\n totalMembers: users.length,\n departments: [...new Set(users.map(u => u.role))],\n payrollTotal: users.reduce((sum, u) => sum + u.salary, 0)\n },\n formattedData: {\n emailList,\n csvFormat,\n jsonForApi: users.map(user => ({\n id: user.name.toLowerCase().replace(' ', '_'),\n displayName: user.name,\n contact: user.email,\n position: user.role,\n compensation: user.salary,\n eligibleForVoting: user.age >= 18\n }))\n }\n};\n\nreturn [{ json: report }];"
},
"typeVersion": 2
}
],
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "bb114702-f10c-42ed-90e4-dd9ff6421c8e",
"connections": {
"Set Sample Data": {
"main": [
[
{
"node": "Code: Filter & Transform",
"type": "main",
"index": 0
},
{
"node": "Code: Calculate Stats",
"type": "main",
"index": 0
},
{
"node": "Code: Format for Export",
"type": "main",
"index": 0
}
]
]
},
"When clicking \u2018Execute workflow\u2019": {
"main": [
[
{
"node": "Set Sample Data",
"type": "main",
"index": 0
}
]
]
}
}
}
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
A comprehensive educational workflow that demonstrates practical JavaScript usage in n8n's Code node through real-world business scenarios. Perfect for learning data manipulation, transformation, and automation patterns that you can immediately apply to client projects. What…
Source: https://n8n.io/workflows/5729/ — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
Blotato. Uses googleSheets, @blotato/n8n-nodes-blotato. Event-driven trigger; 65 nodes.
This template is a hands-on, practical exam designed to help you master n8n Expressions—the key to accessing and manipulating data in your workflows.
This template is a hands-on, practical exam designed to test your understanding of the fundamental JSON data types. It's the perfect way to solidify your knowledge after learning the basics.
Agendamiento. Uses n8n-nodes-evolution-api, redis, dataTable, executeWorkflowTrigger. Event-driven trigger; 60 nodes.
Kv Cloudflare Key Value Database Full Api Integration Workflow. Uses stickyNote, httpRequest, manualTrigger. Event-driven trigger; 47 nodes.