Transformers.js is a machine learning library that enables you to run transformer models directly in web browsers without requiring a backend server.
The library solves the problem of deploying machine learning inference to client-side environments by leveraging ONNX Runtime to execute transformer models in the browser. It provides a JavaScript API designed to be functionally equivalent to Hugging Face's Python transformers library, allowing developers to use familiar patterns while working in web contexts. The tool supports a broad range of tasks across multiple modalities: natural language processing including text classification, named entity recognition, question answering, and text generation; computer vision tasks such as image classification, object detection, and segmentation; audio processing including automatic speech recognition and text-to-speech; and multimodal capabilities like zero-shot classification and embeddings. Models can be converted to ONNX format from PyTorch, TensorFlow, or JAX using Hugging Face Optimum, then deployed through the library.
Developers should adopt this tool when building web applications that need machine learning inference without server round-trips, such as privacy-sensitive applications, offline-capable tools, or performance-critical interfaces. It suits projects where latency matters and where keeping computation on the client side provides user experience or privacy benefits. The library can be installed via NPM or used directly in vanilla JavaScript through CDN delivery without a bundler.
The project maintains a substantial user base, with nearly all open issues originating from external users rather than the core team. Maintainers typically respond to new issues and pull requests within a day. Work in the issue tracker centers on bug reports, user questions, and enhancement requests.