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-as-code/transformer

v1.0.2

Published

Bidirectional transformer: n8n JSON workflows ↔ TypeScript

Readme

@n8n-as-code/transformer

✨ NEW in v0.2.0: This package enables the new TypeScript workflow format (.workflow.ts) that replaces JSON as the default storage format across n8n-as-code.

Bidirectional transformer for n8n workflows: JSON ↔ TypeScript

Overview

This package provides the core transformation engine that converts:

  • JSON → TypeScript: n8n workflow JSON (from API) → TypeScript class with decorators
  • TypeScript → JSON: TypeScript workflow class → n8n workflow JSON (for API)

It is the shared foundation consumed by the CLI, the skills package, and the VS Code extension.

Features

  • Bidirectional transformation with roundtrip support
  • TypeScript decorators for clean, readable workflow definitions
  • Auto-layout support for AI-generated workflows (optional positions)
  • Name collision handling (HttpRequest1, HttpRequest2, ...)
  • Prettier integration for formatted output
  • AI dependency injection syntax for LangChain nodes

Installation

npm install @n8n-as-code/transformer

Usage

For Workflow Authors (TypeScript)

import { workflow, node, links } from '@n8n-as-code/transformer';

@workflow({
    id: "unique-workflow-id",
    name: "My Workflow",
    active: true,
    settings: { executionOrder: "v1" }
})
export class MyWorkflow {
    
    @node({
        name: "Schedule Trigger",
        type: "n8n-nodes-base.scheduleTrigger",
        version: 1.2,
        position: [0, 0]
    })
    ScheduleTrigger = {
        rule: {
            interval: [{
                field: "cronExpression",
                expression: "0 9 * * 1-5"
            }]
        }
    };
    
    @node({
        name: "HTTP Request",
        type: "n8n-nodes-base.httpRequest",
        version: 4,
        position: [200, 0]
    })
    HttpRequest = {
        url: "https://api.example.com/data",
        method: "GET"
    };
    
    @links()
    defineRouting() {
        this.ScheduleTrigger.out(0).to(this.HttpRequest.in(0));
    }
}

For Package Developers (Transformation)

import { JsonToAstParser, AstToTypeScriptGenerator } from '@n8n-as-code/transformer';

// JSON → TypeScript
const parser = new JsonToAstParser();
const ast = parser.parse(workflowJson);

const generator = new AstToTypeScriptGenerator();
const tsCode = await generator.generate(ast, {
    format: true,
    commentStyle: 'verbose'
});

console.log(tsCode); // Ready to write to .workflow.ts file
import { TypeScriptParser, WorkflowBuilder } from '@n8n-as-code/transformer';

// TypeScript → JSON (Phase 2 - coming soon)
const parser = new TypeScriptParser();
const ast = await parser.parseFile('my-workflow.ts');

const builder = new WorkflowBuilder();
const workflowJson = builder.build(ast);

console.log(workflowJson); // Ready to push to n8n API

Architecture

┌─────────────────────────────────────────────┐
│                                             │
│  n8n JSON Workflow (API)                   │
│                                             │
└──────────────┬──────────────────────────────┘
               │
               │ JsonToAstParser
               ▼
┌─────────────────────────────────────────────┐
│                                             │
│  WorkflowAST (Intermediate)                │
│  - Normalized structure                     │
│  - Property names instead of UUIDs          │
│                                             │
└──────────────┬──────────────────────────────┘
               │
               │ AstToTypeScriptGenerator
               ▼
┌─────────────────────────────────────────────┐
│                                             │
│  TypeScript Workflow (.workflow.ts)        │
│  - Decorators (@workflow, @node, @links)   │
│  - Human-readable property names            │
│  - Formatted with Prettier                  │
│                                             │
└─────────────────────────────────────────────┘

Status

  • Phase 1: Architecture & decorators (COMPLETE)
  • 🚧 Phase 2: Core transformation logic (IN PROGRESS)
  • Phase 3: Integration with @n8n-as-code/sync
  • Phase 4: Integration with @n8n-as-code/skills

API Reference

Decorators

@workflow(metadata)

Marks a class as an n8n workflow.

Parameters:

  • id: Workflow ID (UUID)
  • name: Workflow name
  • active: Whether workflow is active
  • settings?: Workflow settings (executionOrder, etc.)

@node(metadata)

Marks a property as an n8n node.

Parameters:

  • name: Node display name
  • type: Node type (e.g., "n8n-nodes-base.httpRequest")
  • version: Node version
  • position?: [x, y] coordinates (optional for auto-layout)
  • credentials?: Node credentials
  • onError?: Error handling behavior

@links()

Marks the method that defines workflow routing.

Transformation Classes

JsonToAstParser

Parses n8n JSON to intermediate AST.

const parser = new JsonToAstParser();
const ast = parser.parse(workflowJson);

AstToTypeScriptGenerator

Generates TypeScript code from AST.

const generator = new AstToTypeScriptGenerator();
const code = await generator.generate(ast, options);

Options:

  • format?: boolean - Apply Prettier formatting (default: true)
  • commentStyle?: 'minimal' | 'verbose' - Comment style (default: 'verbose')
  • className?: string - Custom class name

Development

# Build
npm run build

# Tests
npm test

# Type check
npm run typecheck

License

See LICENSE in repository root.