Transformers.js

Run Hugging Face Transformers models directly in the browser or Node.js with no server required.

Library
npm
v4.3.0
16,329 stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
79 /100 Good
Development Activity 76
Maintenance 80
Community 68
Maturity 52
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
85 /100 Excellent
Architecture 85
Code Quality 78
Innovation 90
Learning Curve 88

Transformers.js is a JavaScript library from Hugging Face that brings state-of-the-art machine learning models to the browser and Node.js, mirroring the Python transformers API so pretrained models can run entirely client-side via WebGPU or WASM, with no inference server needed.

It ships ready-to-use pipelines for natural language processing, computer vision, audio, and multimodal tasks, using ONNX Runtime under the hood to execute quantized versions of thousands of Hugging Face Hub models directly on end-user devices.

What You Get

  • A pipeline() factory that loads a pretrained model, tokenizer/processor, and config in one call for dozens of NLP, vision, audio, and multimodal tasks
  • WebGPU and WASM execution via ONNX Runtime, with selectable quantization (fp32, fp16, q8, q4) to trade off size and speed
  • Automatic downloading and caching of models from the Hugging Face Hub, with an offline/local-model mode via env.allowRemoteModels
  • A JS API intentionally mirrored to the Python transformers library, easing porting of existing model code
  • Node.js and browser builds (ESM/CJS) with generated TypeScript type definitions

Common Use Cases

  • Running sentiment analysis, summarization, or text generation client-side in a web app without calling an external LLM API
  • Building offline-capable, privacy-preserving ML features (e.g. on-device transcription) that never send user data to a server
  • Prototyping and shipping browser-based demos and Hugging Face Spaces without provisioning inference infrastructure
  • Adding background removal, object detection, or image captioning to a Node.js backend using the same model checkpoints as Python

Under The Hood

Architecture Transformers.js lives in a pnpm monorepo where packages/transformers is the single publishable package. The entry point (src/transformers.js) re-exports a layered API: env.js for global configuration, pipelines.js as the high-level task factory, per-architecture classes under models/ plus models/auto/ for automatic model/tokenizer/processor resolution, generation/ for streamers/stopping-criteria/logits-processors mirroring the Python transformers generation loop, and backends/onnx.js (391 lines) abstracting ONNX Runtime session creation across web and Node execution providers. A pipeline() call resolves the task, fetches config/weights through utils/hub.js and utils/model_registry/, runs inference through the ONNX backend, and post-processes output in the matching pipelines/ class.

Tech Stack The library is authored in plain JavaScript with JSDoc type annotations, compiled to .d.ts declarations via tsc --build (the typegen script), and bundled for web/Node ESM+CJS with esbuild (scripts/build.mjs). Core inference runs on onnxruntime-web/onnxruntime-node; @huggingface/jinja handles chat-template rendering, @huggingface/tokenizers handles tokenization, and sharp provides native image decoding in Node. The package publishes dist/transformers.web.js, dist/transformers.node.mjs, and dist/transformers.node.cjs builds from one source tree.

Code Quality Tests are organized by domain (25 top-level *.test.js files plus per-model subfolders under tests/models/) and run through Jest with --experimental-vm-modules. JSDoc @param/@typedef annotations are used pervasively (not just for docs but to drive the TypeScript typegen build), and Prettier enforces consistent formatting across the monorepo via per-directory overrides. Naming and API shape are deliberately kept parallel to the Python transformers library to reduce cognitive overhead when porting code.

API Design The single pipeline(task, model?, options?) factory is the primary entry point, with task aliases (e.g. sentiment-analysis for text-classification) and simple device/dtype options (webgpu, q4, q8, etc.) exposed as plain strings rather than nested config objects. The published docs site includes an API reference, guides, and tutorials, and the project links out to a companion transformers.js-examples repo of runnable demos, keeping the barrier to a first working pipeline low.

Used by 7 apps in this directory

TypeScript
99%
AGPL 3.0

Cherry Studio

AI Assistants

52,202

All-in-one AI desktop client with 300+ assistants and multi-model support

View details
89
Repo Health
84
Technical
70
Dependency
Built with
TypeScript 99%
Updated 1 weeks ago
TypeScript
63%
Apache 2.0

Gemma Gem

AI Assistants

970

A Chrome extension running Google's Gemma 4 model entirely on-device via WebGPU — a browser AI assistant that reads pages, clicks buttons, fills forms, and runs JavaScript with no API keys or cloud dependency.

View details
30
Repo Health
66
Technical
87
Dependency
Built with
TypeScript 63%
JavaScript 37%
Updated 4 months ago
TypeScript
77%
Other

Joplin

Note Taking

56,513

The privacy-first, open-source note-taking app with end-to-end encrypted sync, AI assistance, and a powerful plugin ecosystem across every platform.

View details
93
Repo Health
87
Technical
60
Dependency
Built with
TypeScript 77%
JavaScript 14%
Updated 1 weeks ago
Rust
43%
Apache 2.0

LanceDB

AI Development · Databases

11,544

Open-source, embedded vector database built on the Lance columnar format for fast multimodal search across billions of vectors, backed by Y Combinator (W23).

View details
90
Repo Health
86
Technical
71
Dependency
Built with
Rust 43%
Python 25%
HTML 23%
Updated 1 weeks ago
Rust
71%
Apache 2.0

mesh-llm

AI Agents · AI Development

3,463

Mesh LLM pools GPUs and memory across every machine you own into one OpenAI-compatible API, so agents tap distributed compute instead of a single GPU box or a metered cloud bill.

View details
84
Repo Health
91
Technical
69
Dependency
Built with
Rust 71%
TypeScript 13%
Python 10%
Updated 1 weeks ago
Python
37%
Other

Open WebUI

AI Agents · AI Assistants

153,390

The extensible, privacy-first AI platform that runs Ollama, OpenAI, and any LLM backend behind a polished, feature-packed web interface.

View details
91
Repo Health
75
Technical
66
Dependency
Built with
Python 37%
Svelte 34%
JavaScript 21%
Updated 1 weeks ago
TypeScript
93%
MIT

OpenReel Video

Video Editors

5,211

A browser-based, GPU-accelerated video editor with multi-track timelines, color grading, and 4K export — no uploads, no installs, no watermarks.

View details
66
Repo Health
80
Technical
74
Dependency
Built with
TypeScript 93%
Updated 1 months ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers