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

comfy-api-helper

v1.1.1

Published

A Typescript helper library to make using the ComfyUI API easier

Downloads

8

Readme

Comfy API Helper

A lightweight Typescript helper library to make using the ComfyUI API easier.

Installation

You can install the package using your favorite package manager:

npm install comfy-api-helper
bun add comfy-api-helper

Usage

This library provides simple functions to generate images using your ComfyUI instance.

First, you need a workflow. You can create one in the ComfyUI interface and then export it using the File -> Save (API Format) button. This will give you a JSON file representing the workflow. You can then load this JSON file into your application and modify it as needed.

If using programatically, you may want to wrap the JSON in a Typescript function to replace common inputs like prompt and seed. See example/workflow.ts for an example.

Example

Here's a basic example of how to generate an image and save it to a file:

import fs from 'fs';
import { generateImage } from 'comfy-api-helper';

// 1. Load your workflow API JSON file.
// This is the file you get from ComfyUI's "Save (API Format)" feature.
const workflow = require('./workflow_api.json');

// 2. Set your ComfyUI server endpoint.
const COMFY_ENDPOINT = 'http://127.0.0.1:8188';

// 3. (Optional) Modify the workflow.
// For example, to change the prompt, you need to know the ID of the node you want to change.
// In this example, we're changing the text of a node with ID "6".
workflow['6'].inputs.text = 'a beautiful landscape painting';

async function main() {
  try {
    // 4. Generate the image.
    const imageBuffer = await generateImage(workflow, COMFY_ENDPOINT);

    // 5. Save the image to a file.
    fs.writeFileSync('output.png', imageBuffer);
    console.log('Image saved as output.png');
  } catch (error) {
    console.error('Error generating image:', error);
  }
}

main();

See example/example.ts for a full example.

API

generateImage(workflow, comfyEndpoint, outputFormat)

Generates an image and returns it as a Buffer.

  • workflow (any): A workflow object from ComfyUI's "Save (API Format)" feature. You can modify this object to change parameters like prompts, seeds, etc.
  • comfyEndpoint (string): The URL of your ComfyUI instance (e.g., 'http://127.0.0.1:8188').
  • outputFormat ('png' | 'webp'): The desired output format. Defaults to 'png'.

Returns: Promise<Buffer> - A promise that resolves to the image buffer.

generateImageToDataUri(workflow, comfyEndpoint, outputFormat)

A convenience function that calls generateImage and returns the image as a Data URI, ready to be used in <img> tags or other web contexts.

  • workflow (any): A workflow object.
  • comfyEndpoint (string): The URL of your ComfyUI instance.
  • outputFormat ('png' | 'webp'): The desired output format. Defaults to 'png'.

Returns: Promise<string> - A promise that resolves to the Data URI.

generateImageToBase64String(workflow, comfyEndpoint, outputFormat)

A convenience function that calls generateImage and returns the image as a raw base64-encoded string.

  • workflow (any): A workflow object.
  • comfyEndpoint (string): The URL of your ComfyUI instance.
  • outputFormat ('png' | 'webp'): The desired output format. Defaults to 'png'.

Returns: Promise<string> - A promise that resolves to the base64 string.

License

This project is licensed under the MIT License.