Skip to main content

n8n Custom Nodes: Build, Test and Publish Your Own

Build an n8n custom node: scaffold with npm create @n8n/node, pick declarative or programmatic style, test with npm run dev, then install or publish it.

Founder of IImagined.ai

Published
Jan 15, 2025
Updated
Oct 14, 2026
Reading time
12 min read
Quick answer

To build an n8n custom node, run npm create @n8n/node@latest, pick the HTTP API (declarative) or Other (programmatic) template, define your operations and credential, then run npm run dev to test it in a local n8n at localhost:5678. Install it privately on a self-hosted instance, or publish it to npm as a community node. n8n Cloud installs only verified community nodes, and from 1 May 2026 every community node must be published from a GitHub Action with npm provenance.

An n8n custom node is a TypeScript package that adds your own node to the n8n editor, and n8n's CLI scaffolds, tests and publishes it. Run npm create @n8n/node@latest, describe the API calls, test with npm run dev, then install the build on your own instance or publish it to npm as a community node.

Checked against n8n's node-building docs (development environment, the n8n-node tool, verification guidelines), the community node installation overview, the 3.0 breaking changes and the n8n-nodes-starter repository, on 1 and 14 October 2026. An earlier version of this page used a deprecated request helper, labelled a programmatic example as declarative and quoted client results that could not be verified.

Quick answer: from nothing to a published node
  1. 1
    Scaffold

    npm create @n8n/node@latest, then HTTP API or Other.

  2. 2
    Write the credential

    The fields users fill in and how they attach to each request.

  3. 3
    Describe the operations

    Routing for a declarative node, execute() for a programmatic one.

  4. 4
    Test locally

    npm run dev opens an n8n with your node loaded at localhost:5678.

  5. 5
    Lint

    npm run lint, or lint:fix, before every release.

  6. 6
    Install or publish

    Mount dist on your own instance, or npm run release.

When is a custom node worth building?

Less often than you would think. The HTTP Request node reaches any REST API and can be an AI agent tool, as our n8n API integration guide shows. Build a node when:

  • The same API calls repeat across many workflows and you want one tested, documented component.
  • Teammates who do not read API docs need clean fields, dropdowns and a reusable credential.
  • You connect to an internal or niche system that has no built-in node.
  • You want to publish an integration for other n8n users.

The Code node is not a shortcut around either: n8n's Code node docs say it cannot make HTTP requests or touch the file system. Check how many integrations n8n already has before you start, in case the node exists.

Declarative or programmatic?

Declarative, by default. n8n's style guide says: "Build your node in the declarative style. It's the default for new nodes."

The two node-building styles
Declarative
  • JSON-like routing on each operation and field
  • No execute() method to write
  • Made for REST APIs
  • Less code, fewer bugs
  • Cannot build trigger nodes
Programmatic
  • An execute() method reads items and makes the requests
  • Required for trigger nodes
  • Suits GraphQL and other non-REST APIs
  • Handles heavier processing of each item
  • More code to maintain

Source: n8n docs, checked October 2026

You can mix both in one package: a declarative action node and a programmatic trigger node for the same service is a common pair, and n8n's verification rules allow a trigger for the same service.

What do you need installed?

ToolVersionWhy
Node.js and npm22.22.0 or latern8n suggests installing both with nvm
gitAny current versionThe starter repository and release flow use it
VS CodeRecommendedWith ESLint, EditorConfig and Prettier, the node linter warns as you type
Docker or PodmanFrom n8n 3.0npm run dev starts n8n in a container. Not needed with --external-n8n
TypeScript and REST API knowledgeWorking levelNodes are TypeScript classes describing API calls

The n8n-node tool bundles an n8n for local development, so you do not need n8n installed globally. To run your own instance instead of the container, use n8n-node dev --external-n8n and start that instance with N8N_DEV_RELOAD=true. Note that n8n 3.0 had no installable release when this was checked; the Docker requirement applies once you are on it.

Step 1: scaffold the project

npm create @n8n/node@latest

# or install the CLI globally and run: n8n-node new
npm install --global @n8n/node-cli

The CLI asks three questions (n8n-node docs):

  1. Node name. It must follow n8n-nodes-<name> or @<org>/n8n-nodes-<name>.
  2. Kind of node. HTTP API (declarative) or Other (programmatic). Pick Other for trigger nodes.
  3. Template. GitHub Issues API (a demo) or Start from scratch, which then asks for the API base URL and authentication: API Key, Bearer Token, OAuth2, Basic Auth, Custom or None.

To skip the prompts, pass a name and one of the three templates, declarative/github-issues, declarative/custom or programmatic/example. With the npm create form, put -- before any options:

npm create @n8n/node@latest n8n-nodes-acme-crm -- --template declarative/custom

Step 2: know the project layout and scripts

n8n-nodes-acme-crm/
  credentials/
    AcmeCrmApi.credentials.ts
  nodes/
    AcmeCrm/
      AcmeCrm.node.ts
      AcmeCrm.node.json   # codex file: categories and docs links
      acmecrm.svg
  package.json
  tsconfig.json

The generated package.json wires the scripts to the CLI and registers the built files in its n8n section:

"scripts": {
  "build": "n8n-node build",
  "dev": "n8n-node dev",
  "lint": "n8n-node lint",
  "lint:fix": "n8n-node lint --fix",
  "release": "n8n-node release"
},
"keywords": ["n8n-community-node-package"],
"n8n": {
  "n8nNodesApiVersion": 1,
  "strict": true,
  "credentials": ["dist/credentials/AcmeCrmApi.credentials.js"],
  "nodes": ["dist/nodes/AcmeCrm/AcmeCrm.node.js"]
}

Keep the class name and file name identical: a class AcmeCrm lives in AcmeCrm.node.ts.

Step 3: write the credential

A credential file defines the fields users fill in and how n8n attaches them to requests. authenticate adds the key to every call, and test lets n8n check it when the user saves (see credentials files):

// credentials/AcmeCrmApi.credentials.ts
import type {
  IAuthenticateGeneric,
  ICredentialTestRequest,
  ICredentialType,
  INodeProperties,
} from 'n8n-workflow';

export class AcmeCrmApi implements ICredentialType {
  name = 'acmeCrmApi';
  displayName = 'Acme CRM API';
  documentationUrl = 'https://docs.acme-crm.example/api/auth';

  properties: INodeProperties[] = [
    {
      displayName: 'API Key',
      name: 'apiKey',
      type: 'string',
      typeOptions: { password: true },
      default: '',
    },
  ];

  authenticate: IAuthenticateGeneric = {
    type: 'generic',
    properties: {
      headers: { Authorization: '=Bearer {{$credentials.apiKey}}' },
    },
  };

  test: ICredentialTestRequest = {
    request: { baseURL: 'https://api.acme-crm.example/v1', url: '/me' },
  };
}

The name here must match the name in the node's credentials array exactly, or n8n reports that the credential type is not known.

Step 4: write a declarative node

This node creates and fetches contacts in a fictional Acme CRM. requestDefaults sets the base URL, each operation's routing sets the method and path, and routing.send puts a field into the request body. The pattern follows n8n's declarative tutorial and the starter's GitHub Issues node.

// nodes/AcmeCrm/AcmeCrm.node.ts
import { NodeConnectionTypes } from 'n8n-workflow';
import type { INodeType, INodeTypeDescription } from 'n8n-workflow';

export class AcmeCrm implements INodeType {
  description: INodeTypeDescription = {
    displayName: 'Acme CRM',
    name: 'acmeCrm',
    icon: 'file:acmecrm.svg',
    group: ['transform'],
    version: 1,
    subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
    description: 'Create and read contacts in Acme CRM',
    defaults: { name: 'Acme CRM' },
    usableAsTool: true,
    inputs: [NodeConnectionTypes.Main],
    outputs: [NodeConnectionTypes.Main],
    credentials: [{ name: 'acmeCrmApi', required: true }],
    requestDefaults: {
      baseURL: 'https://api.acme-crm.example/v1',
      headers: { Accept: 'application/json', 'Content-Type': 'application/json' },
    },
    properties: [
      {
        displayName: 'Resource',
        name: 'resource',
        type: 'options',
        noDataExpression: true,
        options: [{ name: 'Contact', value: 'contact' }],
        default: 'contact',
      },
      {
        displayName: 'Operation',
        name: 'operation',
        type: 'options',
        noDataExpression: true,
        displayOptions: { show: { resource: ['contact'] } },
        options: [
          {
            name: 'Create',
            value: 'create',
            action: 'Create a contact',
            routing: { request: { method: 'POST', url: '/contacts' } },
          },
          {
            name: 'Get',
            value: 'get',
            action: 'Get a contact',
            routing: { request: { method: 'GET', url: '=/contacts/{{$parameter.contactId}}' } },
          },
        ],
        default: 'create',
      },
      {
        displayName: 'Email',
        name: 'email',
        type: 'string',
        placeholder: 'name@example.com',
        required: true,
        default: '',
        displayOptions: { show: { resource: ['contact'], operation: ['create'] } },
        routing: { send: { type: 'body', property: 'email' } },
      },
      {
        displayName: 'Contact ID',
        name: 'contactId',
        type: 'string',
        required: true,
        default: '',
        displayOptions: { show: { resource: ['contact'], operation: ['get'] } },
      },
    ],
  };
}

usableAsTool: true, which n8n's tutorials include, lets the AI Agent node call your node as a tool. Optional parameters usually go in an Additional Fields collection so the default view stays short.

When do you need the programmatic style?

For triggers and anything routing cannot express. Programmatic nodes implement execute() and make requests with this.helpers.httpRequestWithAuthentication; the HTTP request helpers reference says new nodes should use it rather than the deprecated this.helpers.request. Loop over items, keep item links, and wrap API failures in NodeApiError:

import type { IDataObject, IExecuteFunctions, INodeExecutionData, JsonObject } from 'n8n-workflow';
import { NodeApiError } from 'n8n-workflow';

// Inside the node class:
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
  const items = this.getInputData();
  const returnData: INodeExecutionData[] = [];

  for (let i = 0; i < items.length; i++) {
    try {
      const email = this.getNodeParameter('email', i) as string;
      const response = await this.helpers.httpRequestWithAuthentication.call(this, 'acmeCrmApi', {
        method: 'POST',
        url: 'https://api.acme-crm.example/v1/contacts',
        body: { email },
        json: true,
      });
      returnData.push(
        ...this.helpers.constructExecutionMetaData(
          this.helpers.returnJsonArray(response as IDataObject),
          { itemData: { item: i } },
        ),
      );
    } catch (error) {
      if (this.continueOnFail()) {
        returnData.push({ json: { error: (error as Error).message }, pairedItem: { item: i } });
        continue;
      }
      throw new NodeApiError(this.getNode(), error as JsonObject);
    }
  }

  return [returnData];
}

Use NodeOperationError for validation and configuration problems and NodeApiError for failures from the external service. n8n's error handling reference shows custom messages for codes such as 401 and 404, and our n8n error handling guide covers the workflow side.

Step 5: test it locally

npm run dev
# then open http://localhost:5678 and search for "Acme CRM" in the nodes panel
What npm run dev does
  1. 01
    Compiles the project

    TypeScript in, the dist folder out.

  2. 02
    Starts a local n8n

    From 3.0 in a container; or your own instance with --external-n8n.

  3. 03
    Loads your node

    Search for it by display name in the nodes panel.

  4. 04
    Watches for changes

    Rebuilds on save. Description changes need a restart.

Search by the node's display name, not the package name. Stop and restart the command after changing description properties, since those do not refresh live. Run npm run lint (or npm run lint:fix) before every release.

Step 6: install it on your own n8n

For a private node you will not publish, build it and give a self-hosted n8n the files in dist. n8n loads every *.node.js and *.credentials.js it finds in ~/.n8n/custom or a folder named by N8N_CUSTOM_EXTENSIONS:

npm run build

docker run -it --rm --name n8n -p 5678:5678 \
  -v n8n_data:/home/node/.n8n \
  -v "$(pwd)/dist":/home/node/custom-nodes \
  -e N8N_CUSTOM_EXTENSIONS=/home/node/custom-nodes \
  n8nio/n8n

The other routes, depending on where the node lives and where n8n runs:

RouteHowWhere it works
Private filesBuild, then mount dist into ~/.n8n/custom or a folder named by N8N_CUSTOM_EXTENSIONSSelf-hosted only
Nodes panelSearch and install a verified community nodeCloud and self-hosted
Settings, Community NodesInstall a package from npm by name, optionally with a versionSelf-hosted
Command linenpm i the package in ~/.n8n/nodes inside the container, then restart. For queue mode or private registriesSelf-hosted
Environment variablesN8N_COMMUNITY_PACKAGES_MANAGED_BY_ENV=true and a list in N8N_COMMUNITY_PACKAGES. Packages not listed are removed on startSelf-hosted, n8n 2.21.0 and later
Where a node can run
Self-hosted
Installs from the nodes panel, by owners and admins.
Not available. n8n says unverified nodes need self-hosting.
n8n Cloud
Installs from the nodes panel or Settings, Community Nodes.
Works. From 3.0, unverified npm packages need N8N_UNVERIFIED_PACKAGES_ENABLED=true.
Verified community node
Unverified or private node

That last point is easy to miss: n8n 3.0 changes the default of N8N_UNVERIFIED_PACKAGES_ENABLED from true to false. Our n8n 3.0 upgrade guide covers the other changes for node authors, including the removal of defaults.color and the move of n8n-node dev test data to a per-image volume.

Step 7: publish and get verified

Log in with npm login and run npm run release, which builds, lints, updates the changelog, tags, creates a GitHub release and publishes to npm. Verification is what lets Cloud users install your node from the nodes panel.

n8n's verification requirements
  • Built with the n8n-node tool
  • MIT licence
  • No external dependencies
  • Never reads environment variables or files
  • One third-party service per package, and not a copy of an existing node
  • Not a logic or flow-control node, which n8n is not accepting
  • Interface and documentation in English, with a README and example workflows
  • Passes npx @n8n/scan-community-package n8n-nodes-yourname
  • Published from a GitHub Action with an npm provenance statement, required from 1 May 2026
  • A public repository whose URL and author match the npm package

The provenance rule is the one older packages trip on: see npm's page on provenance statements and the publish workflow in the starter repository. Then submit the package in the n8n Creator Portal, following the submission docs.

Troubleshooting

The node does not appear in the nodes panel

Search by display name, check that the n8n.nodes paths in package.json point to files that exist in dist, rebuild, and restart the dev command.

"Credentials of type ... aren't known"

The name in your credential class and the node's credentials array do not match.

The icon is missing or distorted

Keep the SVG or a 60x60 PNG in the node's folder, reference it as file:acmecrm.svg, and use a square canvas. From 3.0, Font Awesome icons show in a neutral colour, so a file icon is the safer choice.

A 401 from the API

Check the header format your API expects (some want Bearer, some a custom header or a query parameter), and test the same key with curl first.

The linter keeps flagging a renamed file on Windows

n8n's troubleshooting notes describe a Windows issue with case-only renames. Rename to a different name first, then to the correct case.

A note on security

The full wording is on n8n's community node risks page.

Where to go next

If you are building nodes for client projects, pair this with our guides to self-hosting n8n, version control for n8n and the n8n MCP server trigger. The AI automation library lists every related guide. If you would rather build your own AI product than nodes for clients, AI SaaS Builder covers tool use with the Claude API and building your own MCP server, along with Supabase, Next.js and Stripe billing.

n8n custom nodes: FAQ

How do I create a custom node in n8n?

Run npm create @n8n/node@latest, choose HTTP API for a declarative node or Other for a programmatic one, and define your operations and credential. Then run npm run dev, open localhost:5678 and search for the node by its display name in the nodes panel. The same CLI builds, lints and releases the package when it is ready.

Can I use custom nodes on n8n Cloud?

Only verified community nodes, which owners and admins install from the nodes panel. n8n's docs say unverified community nodes are not available on n8n Cloud and need a self-hosted instance, and the same goes for a private node you never publish. If your users are on Cloud, plan for verification from the start.

Should I build a declarative or programmatic n8n node?

Declarative, unless you have a reason not to. n8n's style guide calls it the default for new nodes, and it needs no execute() method. Use the programmatic style for trigger nodes, which the declarative style does not support, for APIs that are not REST such as GraphQL, and for heavier processing of each item.

What do I need installed to build an n8n node?

Node.js 22.22.0 or later with npm, and git, per n8n's development environment page. n8n recommends VS Code with the ESLint, EditorConfig and Prettier extensions, so the node linter's warnings show as you type. From n8n 3.0, npm run dev starts n8n in a container, so you also need Docker or Podman, unless you point the CLI at an instance you run yourself.

How do I get my n8n node verified?

Build it with the n8n-node tool, use the MIT licence, ship no external dependencies, never read environment variables or files, integrate one service per package, keep the interface and docs in English, and pass npx @n8n/scan-community-package. From 1 May 2026 every community node must be published from a GitHub Action with an npm provenance statement. Then submit it in the n8n Creator Portal.

Why does my custom node not appear in n8n?

Search by the display name, not the package name. Check that the n8n section of package.json points to built files that exist in dist, rebuild, and restart npm run dev after changing description properties, which do not refresh live. In Docker, confirm the built files sit in ~/.n8n/custom or a folder named by N8N_CUSTOM_EXTENSIONS.

Are community nodes safe to install?

Treat them like any third-party code. n8n warns that community nodes have full access to the machine n8n runs on and to the data in your workflows. Prefer verified nodes, install unverified ones only from sources you trust, and pin versions. Self-hosted admins can turn community nodes off with N8N_COMMUNITY_PACKAGES_ENABLED=false.

Free · no card needed

Start with the free Starter Kit.

A unit economics calculator from AI SaaS Builder, plus four more working files.

Starter Kit5 files · free
See All Access: $99/mo →30-day money-back guarantee