npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

n8n-nodes-tool-workflow-transformer

v0.1.4

Published

n8n AI tool node to execute workflows with JavaScript output transformation

Downloads

12

Readme

n8n Tool Workflow with Transformer

A custom n8n node that executes workflows as AI agent tools with JavaScript output transformation capabilities.

🎯 Overview

The Tool Workflow with Transformer node is based on the official n8n ToolWorkflow node, but adds a powerful feature: the ability to transform the workflow output using custom JavaScript code before returning it to the AI agent.

This is particularly useful when you need to:

  • Format workflow output for specific AI agent requirements
  • Extract only relevant data from complex workflow results
  • Convert data structures to match expected formats
  • Summarize or aggregate workflow outputs

✨ Features

  • 🤖 AI Tool Integration: Designed to work as a tool for AI agents
  • 🔄 Workflow Execution: Execute any n8n workflow from database or JSON
  • 🔧 Output Transformation: Transform workflow output with custom JavaScript
  • 📦 Flexible Input/Output: Handle various data formats
  • Error Handling: Robust error handling and reporting

📦 Installation

Using npm

npm install n8n-nodes-tool-workflow-transformer

Local Development

  1. Clone the repository:
git clone https://github.com/your-org/n8n-nodes-tool-workflow-transformer.git
cd n8n-nodes-tool-workflow-transformer
  1. Install dependencies:
npm install
  1. Build the project:
npm run build
  1. Link to n8n:
npm link
cd /path/to/n8n
npm link n8n-nodes-tool-workflow-transformer

🔧 Node Configuration

Parameters

Tool Configuration

  • Name: The name of the tool function (alphanumeric with underscores)
  • Description: Description of what the tool does for the AI agent

Workflow Source

  • Source: Choose between:
    • Database: Load workflow by ID from n8n database
    • Define Below: Provide workflow JSON directly

Transformation

  • Transform Output: Toggle to enable/disable output transformation
  • Transformation Code: JavaScript code to transform the workflow output

Transformation Variables

The transformation code has access to:

  • $output: The output from the executed workflow (object or array)
  • $input: The input that was sent to the workflow

📝 Usage Examples

Example 1: Extract Specific Fields

// Extract only names from an array of objects
if (Array.isArray($output)) {
  return $output.map(item => item.name).join(', ');
}
return $output.name || 'Unknown';

Example 2: Format for AI Response

// Format workflow output as a structured message
const count = Array.isArray($output) ? $output.length : 1;
return `Found ${count} results. Details: ${JSON.stringify($output, null, 2)}`;

Example 3: Aggregate Data

// Sum values from workflow output
if (Array.isArray($output)) {
  const total = $output.reduce((sum, item) => sum + (item.value || 0), 0);
  return { total, itemCount: $output.length, average: total / $output.length };
}
return $output;

Example 4: Error Handling

// Safely handle different output types
try {
  if (!$output) return 'No data received';
  
  if (Array.isArray($output)) {
    return $output.filter(item => item.status === 'active');
  }
  
  return $output.status === 'active' ? $output : null;
} catch (error) {
  return `Error processing data: ${error.message}`;
}

🏗️ Architecture

The node extends the standard n8n workflow execution with:

  1. Workflow Execution: Executes the specified workflow with provided inputs
  2. Output Capture: Captures the workflow output data
  3. Transformation: Applies JavaScript transformation if enabled
  4. Result Return: Returns the (transformed) result to the AI agent

🛠️ Development

Project Structure

n8n-nodes-tool-workflow-transformer/
├── nodes/
│   ├── ToolWorkflowWithTransformer.node.ts
│   └── toolWorkflowWithTransformer.svg
├── dist/                 # Compiled files
├── package.json
└── tsconfig.json

Available Scripts

  • npm run build - Build the TypeScript code
  • npm run dev - Build in watch mode
  • npm run lint - Run ESLint
  • npm run lintfix - Fix linting issues

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📄 License

MIT

🆘 Support

For issues or questions, please open an issue on GitHub.

🔗 Links