What problem does it solve?
Writing JavaScript inside n8n Code nodes often leads to tangled data access, inconsistent return formats, and boilerplate error handling. This skill consolidates best practices for using $input, $json, and $node, with built-in helpers like $helpers.httpRequest and DateTime (Luxon) to enable reliable data transformations, API interactions, and webhook payload processing.
Core Features & Use Cases
- Data access patterns: $input.all(), $input.first(), and $input.item for batch vs per-item logic.
- Return format discipline: always return an array of objects with a json field, and ensure webhook payloads are accessed via .body when applicable.
- Built-in helpers: use $helpers.httpRequest() for API calls, DateTime for date/time operations, and $jmespath() for JSON querying.
- Production patterns: apply common patterns such as multi-source aggregation, top-N filtering, transformation, and reporting.
- Debugging and safety: utilize console logging, try-catch, and null checks to produce robust workflows.
Quick Start
Process the input data with a single run over all items, apply a transformation, and return an array of JSON-wrapped results.