domains / software-engineering / n8n-code-node / n8n-code-javascript
The first copy is a detailed, self-contained procedure with specific syntax, mode-selection performance data, and sandbox constraints. The second copy is a high-level wrapper that delegates to an external file and adds a 'When to Use' decision matrix and safety limitations not present in the first. Because the second copy contains material steps (the decision matrix and safety constraints) that the first lacks, and the first contains the actual implementation details the second lacks, crowning one would hide a real alternative or lose critical context.
| Repository | Path |
|---|---|
| czlonkowski/n8n-skills | skills/n8n-code-javascript/SKILL.md |
| sickn33/agentic-awesome-skills | plugins/agentic-awesome-skills-claude/skills/n8n-code-javascript/SKILL.md |
| Role | Repository | Path |
|---|---|---|
| peer | czlonkowski/n8n-skills | skills/n8n-code-javascript/SKILL.md |
| peer | sickn33/agentic-awesome-skills | plugins/agentic-awesome-skills-claude/skills/n8n-code-javascript/SKILL.md |
| adapter | sickn33/agentic-awesome-skills | plugins/agentic-awesome-skills/skills/n8n-code-javascript/SKILL.md |
| adapter | sickn33/agentic-awesome-skills | skills/n8n-code-javascript/SKILL.md |
---
name: n8n-code-javascript
description: Write JavaScript code in n8n Code nodes. Use when writing JavaScript in n8n, using $input/$json/$node syntax, making HTTP requests with this.helpers, working with dates using DateTime, troubleshooting Code node errors, or choosing between Code node modes.
---
# JavaScript Code Node
## When to Use Code Node
Use Code node when:
- Complex transformations requiring multiple steps
- Custom calculations or business logic
- Recursive operations
- API response parsing with complex structure
- Multi-step conditionals
- Data aggregation across items
Consider other nodes when:
- Simple field mapping → Use Set node
- Basic filtering → Use Filter node
- Simple conditionals → Use IF or Switch node
- HTTP requests only → Use HTTP Request node
## Essential Rules
1. Choose "Run Once for All Items" mode (recommended for most use cases).
2. Access data: $input.all(), $input.first(), or $input.item.
3. Return [{json: {...}}] — the canonical, mode-portable form.
4. CRITICAL: Webhook data is under $json.body (not $json directly).
5. Built-ins available: this.helpers.httpRequest() (no auth), DateTime (Luxon), $jmespath().
- Note: The bare $helpers global is undefined in the task-runner sandbox.
- Not available: this.helpers.httpRequestWithAuthentication, $env (when blocked), require() (unless allowlisted).
6. For anything beyond a trivial unauthenticated GET, prefer the HTTP Request node.
## Mode Selection Guide
### Run Once for All Items (Recommended)
- Use for: Aggregation, filtering, batch processing, transformations.
- Data access: $input.all()
- Performance: Faster for multiple items (single execution).
### Run Once for Each Item
- Use for: Item-specific logic, independent operations, per-item validation.
- Data access: $input.item
- Performance: Slower for large datasets (multiple executions).
## Safety & Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.