Write and debug JavaScript code in n8n Code nodes with proper data access and return formatting.
Works with
Supports two execution modes: \"Run Once for All Items\" (recommended for 95% of use cases) and \"Run Once for Each Item\" for specialized per-item logic
Access data via $input.all() , $input.first() , or $input.item ; always return array format [{json: {...}}]
Built-in helpers include $helpers.httpRequest() for HTTP calls, DateTime (Luxon) for date operations, and $jmespath() for JSON qu
AI-first code editor with Composer
Before installing skills in Cursor, ensure your development environment meets these requirements:
node --versionn8n-code-javascriptExecute the skills CLI command in your project's root directory to begin installation:
Fetches n8n-code-javascript from czlonkowski/n8n-skills and configures it for Cursor.
The CLI shows a list of agents. Use arrow keys and space to select Cursor:
Confirm successful installation by checking the skill directory location:
Restart Cursor to activate n8n-code-javascript. Access via /n8n-code-javascript in your agent's command palette.
We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.
Skills execute code in your environment. Always review source, verify the publisher, and test in isolation before production.
Submit your Claude Code skill and start earning
Automate repetitive workflows and reduce manual effort
Example
Generate reports, summarize documents, draft communications
Save 3-5 hours per week on routine tasks
Learn new skills, understand complex topics, get expert guidance
Example
Explain concepts, provide examples, suggest learning resources
Accelerate learning and skill development by 2x
Enhance output quality through reviews, suggestions, and refinements
Example
Review drafts, suggest improvements, catch errors
Improve work quality by 30-40% with less effort
0
total installs
0
this week
4.1K
GitHub stars
0
upvotes
Run in your terminal
0
installs
0
this week
4.1K
stars
Expert guidance for writing JavaScript code in n8n Code nodes.
// Basic template for Code nodes
const items = $input.all();
// Process data
const processed = items.map(item => ({
json: {
...item.json,
processed: true,
timestamp: new Date().toISOString()
}
}));
return processed;
$input.all(), $input.first(), or $input.item[{json: {...}}] format$json.body (not $json directly)The Code node offers two execution modes. Choose based on your use case:
Use this mode for: 95% of use cases
$input.all() or items array// Example: Calculate total from all items
const allItems = $input.all();
const total = allItems.reduce((sum, item) => sum + (item.json.amount || 0), 0);
return [{
json: {
total,
count: allItems.length,
average: total / allItems.length
}
}];
When to use:
Use this mode for: Specialized cases only
$input.item or $item// Example: Add processing timestamp to each item
const item = $input.item;
return [{
json: {
...item.json,
processed: true,
processedAt: new Date().toISOString()
}
}];
When to use:
Decision Shortcut:
Use when: Processing arrays, batch operations, aggregations
// Get all items from previous node
const allItems = $input.all();
// Filter, map, reduce as needed
const valid = allItems.filter(item => item.json.status === 'active');
const mapped = valid.map(item => ({
json: {
id: item.json.id,
name: item.json.name
}
}));
return mapped;
Use when: Working with single objects, API responses, first-in-first-out
// Get first item only
const firstItem = $input.first();
const data = firstItem.json;
return [{
json: {
result: processData(data),
processedAt: new Date().toISOString()
}
}];
Use when: In "Run Once for Each Item" mode
// Current item in loop (Each Item mode only)
const currentItem = $input.item;
return [{
json: {
...currentItem.json,
itemProcessed: true
}
}];
Use when: Need data from specific nodes in workflow
// Get output from specific node
const webhookData = $node["Webhook"].json;
const httpData = $node["HTTP Request"].json;
return [{
json: {
combined: {
webhook: webhookData,
api: httpData
}
}
}];
See: DATA_ACCESS.md for comprehensive guide
MOST COMMON MISTAKE: Webhook data is nested under .body
// ❌ WRONG - Will return undefined
const name = $json.name;
const email = $json.email;
// ✅ CORRECT - Webhook data is under .body
const name = $json.body.name;
const email = $json.body.email;
// Or with $input
const webhookData = $input.first().json.body;
const name = webhookData.name;
Why: Webhook node wraps all request data under body property. This includes POST data, query parameters, and JSON payloads.
See: DATA_ACCESS.md for full webhook structure details
CRITICAL RULE: Always return array of objects with json property
// ✅ Single result
return [{
json: {
field1: value1,
field2: value2
}
}];
// ✅ Multiple results
Implementation Guide
Prerequisites
- ›Claude Desktop or compatible AI client with skill support
- ›Clear understanding of task or problem to solve
- ›Willingness to iterate and refine outputs
Time Estimate
15-45 minutes depending on use case complexity
Steps
- 1Install skill using provided installation command
- 2Test with simple use case relevant to your work
- 3Evaluate output quality and relevance
- 4Iterate on prompts to improve results
- 5Integrate into regular workflow if valuable
Common Pitfalls
- ⚠Expecting perfect results without iteration
- ⚠Not providing enough context in prompts
- ⚠Using skill for tasks outside its intended scope
- ⚠Accepting outputs without review and validation
Best Practices
✓ Do
- +Start with clear, specific prompts
- +Provide relevant context and constraints
- +Review and refine all outputs before using
- +Iterate to improve output quality
- +Document successful prompt patterns
✗ Don't
- −Don't use without understanding skill limitations
- −Don't skip validation of outputs
- −Don't share sensitive information in prompts
- −Don't expect skill to replace human judgment
💡 Pro Tips
- ★Be specific about desired format and style
- ★Ask for multiple options to choose from
- ★Request explanations to understand reasoning
- ★Combine AI efficiency with human expertise
When to Use This
✓ Use when
Use when skill capabilities match your task, clear ROI on time saved, and you can validate outputs. Best for repetitive tasks, learning, and quality improvement.
✗ Avoid when
Avoid when task requires deep expertise you can't validate, involves sensitive decisions, or when learning process is more valuable than speed of completion.
Learning Path
- 1Familiarize yourself with skill capabilities and limitations
- 2Start with low-risk, non-critical tasks
- 3Progress to more complex and valuable use cases
- 4Build expertise through regular use and experimentation
Related Skills
python-expert-best-practices-code-review
44wispbit-ai/skills
Backendtag: codeclean-code-principles
103asyrafhussin/agent-skills
Productivitytag: codeimprove
86shadcn/improve
codetag: codeno-mistakes
32kunchenguid/no-mistakes
devopstag: codecode-simplifier
21simonwong/agent-skills
Productivitytag: codecode-review-excellence
14awesome-skills/code-review-skill
Productivitytag: codeReviews
4.5★★★★★68 reviews- NNaina Ghosh★★★★★Dec 20, 2024
Useful defaults in n8n-code-javascript — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
- HHarper Anderson★★★★★Dec 16, 2024
We added n8n-code-javascript from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.
- HHenry Johnson★★★★★Dec 8, 2024
Registry listing for n8n-code-javascript matched our evaluation — installs cleanly and behaves as described in the markdown.
- CChaitanya Patil★★★★★Dec 4, 2024
Registry listing for n8n-code-javascript matched our evaluation — installs cleanly and behaves as described in the markdown.
- AAlexander Mensah★★★★★Dec 4, 2024
Keeps context tight: n8n-code-javascript is the kind of skill you can hand to a new teammate without a long onboarding doc.
- CCamila Ndlovu★★★★★Nov 27, 2024
Keeps context tight: n8n-code-javascript is the kind of skill you can hand to a new teammate without a long onboarding doc.
- PPiyush G★★★★★Nov 23, 2024
Keeps context tight: n8n-code-javascript is the kind of skill you can hand to a new teammate without a long onboarding doc.
- LLuis Perez★★★★★Nov 23, 2024
Registry listing for n8n-code-javascript matched our evaluation — installs cleanly and behaves as described in the markdown.
- MMeera Anderson★★★★★Nov 11, 2024
I recommend n8n-code-javascript for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
- HHarper Reddy★★★★★Nov 7, 2024
n8n-code-javascript fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.
showing 1-10 of 68
1 / 7Discussion
Comments — not star reviews- No comments yet — start the thread.