Transformers.js

JavaScript library that runs transformer models in the browser or Node.js via ONNX Runtime.

Open SourceSelf HostedOffline Capable
0.0 (0)

About

Hugging Face's Transformers library has a JavaScript twin: Transformers.js runs pretrained models directly in the browser or Node.js with no server, using ONNX Runtime for execution and WebGPU for GPU acceleration. The API deliberately mirrors the Python pipeline interface, so a few lines cover text classification, translation, summarization, object detection, image segmentation, speech recognition, zero-shot classification, and embedding generation, spanning more than 160 model architectures from BERT and Whisper to Llama, Mistral, and Qwen. Models load from the Hugging Face Hub with quantization options at fp32, fp16, q8, and q4 to keep downloads and memory reasonable for client devices. Installation is npm i @huggingface/transformers, or a CDN import for quick prototypes, with the v4 series current. Everything is Apache-2.0 licensed with around 16.2k GitHub stars. Web developers use it to add on-device inference to extensions, PWAs, and sites where privacy, latency, or hosting cost rules out a server-side model.

Should you use Transformers.js?

Pick it when

You build a web app, browser extension, or Node.js service that should run classification, embeddings, speech recognition, or small LLMs client-side with a Python-like pipeline API and no inference server to host.

Look elsewhere when

Skip it when you need chat LLMs in the browser with an OpenAI-style streaming API, where WebLLM is purpose-built, or when models are large or devices lack WebGPU; a server engine like vLLM or Ollama will serve them faster.

Alternatives to Transformers.js

  • WebLLM

    Purpose-built for chat LLMs in the browser with an OpenAI-shaped API and JSON-schema output, but no classification, vision, or speech pipelines.

  • ONNX Runtime

    The runtime under Transformers.js; use it directly for custom models or other languages, at the cost of writing your own pre and post-processing.

  • MLC LLM

    Reaches native iOS, Android, and desktop apps as well as browsers for LLMs, but requires compiling each model first.

Reviews (0)

Leave a Review

No reviews yet. Be the first to review!

Details

Price
Free
Platform
Local/Desktop
Difficulty
Intermediate (3/5)
License
Apache-2.0
Added
Jul 29, 2026

Tags