Transformers.js

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

Library
npm
v4.2.0
16,260stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
75/100Good
Development Activity68
Maintenance72
Community68
Maturity52
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
85/100Excellent
Architecture85
Code Quality78
Innovation90
Learning Curve88

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 6 apps in this directory

TypeScript
99%
AGPL 3.0

Cherry Studio

AI Assistants

50,753

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

View details
88
Repo Health
84
Technical
71
Dependency
Built with
TypeScript99%
Updated today
TypeScript
63%
Apache 2.0

Gemma Gem

AI Assistants

961

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
36
Repo Health
66
Technical
87
Dependency
Built with
TypeScript63%
JavaScript37%
Updated 2 months ago
TypeScript
76%
Other

Joplin

Note Taking

56,003

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
62
Dependency
Built with
TypeScript76%
JavaScript15%
Updated yesterday
Rust
36%
Apache 2.0

LanceDB

Databases · AI Development

11,190

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
72
Dependency
Built with
Rust36%
HTML30%
Python26%
Updated today
Rust
72%
Apache 2.0

mesh-llm

AI Development · AI Agents

3,258

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
83
Repo Health
91
Technical
70
Dependency
Built with
Rust72%
TypeScript16%
Updated today
Python
37%
Other

Open WebUI

AI Assistants · AI Agents

149,204

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
Python37%
Svelte33%
JavaScript22%
Updated today

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

Search