JavaScript machine learning libraries

Updated Nov 2026

JavaScript machine learning libraries train models or run pretrained models in browsers and Node.js. Browser runtimes execute a model on the user's device through WebAssembly or WebGPU rather than on a server. These libraries let web apps classify images, detect faces, and run language models without sending user data to a remote API.

Popularity

ONNX Runtime Node has the most monthly downloads in this comparison, at 36.3M.

LibraryMonthly downloadsStarsLast releaseLicense
onnxruntime-node
36.3M
22.3KOct 2026MIT
@mediapipe/tasks-vision
31.4M
37.7KNov 2026Apache-2.0
@huggingface/transformers
19.1M
16.4KOct 2026Apache-2.0
skmeans
8.8M
76Jan 2020MIT
@tensorflow/tfjs
2.4M
19.2KOct 2024Apache-2.0
ml-kmeans
805.4K
105Jun 2026MIT
ml-logistic-regression
769.8K
18May 2020MIT
@mlc-ai/web-llm
754.5K
19.4KNov 2026Apache-2.0
Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Libraries and code examples

onnxruntime-node

Runs ONNX models in Node.js through a native binding.

Downloads / mo
36.3M
Stars
22.3K
Last release
1.31.1
License
MIT
$ npm install onnxruntime-node
import * as ort from 'onnxruntime-node';
const session = await ort.InferenceSession.create('./model.onnx');
console.log(session);

@mediapipe/tasks-vision

Runs MediaPipe vision tasks in the browser.

Downloads / mo
31.4M
Stars
37.7K
Last release
1.2.3
License
Apache-2.0

Quickstart

From web_js
$ npm install @mediapipe/tasks-vision
import { FilesetResolver, FaceLandmarker } from '@mediapipe/tasks-vision';
const files = await FilesetResolver.forVisionTasks('https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@1.2.3/wasm');
const task = await FaceLandmarker.createFromOptions(files, {
  baseOptions: { modelAssetPath: './face_landmarker.task' }, runningMode: 'IMAGE',
});
console.log(task);

@mediapipe/tasks-vision examples

From open-source projects on GitHub

@huggingface/transformers

Runs Transformers models directly in the browser, with no server.

Downloads / mo
19.1M
Stars
16.4K
Last release
4.3.2
License
Apache-2.0

Quickstart

From README.md
$ npm install @huggingface/transformers
import { pipeline } from '@huggingface/transformers';
const classify = await pipeline('sentiment-analysis');
console.log(await classify('I love transformers!'));

@huggingface/transformers examples

From open-source projects on GitHub

skmeans

Clusters one-dimensional and multidimensional data with k-means and k-means++ in Node.js and the browser.

Downloads / mo
8.8M
Stars
76
Last release
0.11.3
License
MIT

Quickstart

From README.md
$ npm install skmeans
import skmeans from 'skmeans';
const result = skmeans([[1], [2], [10], [11]], 2, 'kmpp');
console.log(result.centroids);

@tensorflow/tfjs

Builds, trains, and deploys machine-learning models in JavaScript.

Downloads / mo
2.4M
Stars
19.2K
Last release
4.22.0
License
Apache-2.0

Strengths

  • Builds models at different levels. Choose low-level tensor operations or the higher-level layers API.
  • Reloads saved model topology. Save topology and weight references in a JSON model file.

Limitations

  • GPU tensors need explicit cleanup. Dispose tensors or use tidy to release unneeded WebGL memory.

Quickstart

From README.md
$ npm install @tensorflow/tfjs
import * as tf from '@tensorflow/tfjs';
const model = tf.sequential();
model.add(tf.layers.dense({ units: 1, inputShape: [1] }));
model.compile({ loss: 'meanSquaredError', optimizer: 'sgd' });
const xs = tf.tensor2d([1, 2, 3, 4], [4, 1]);
const ys = tf.tensor2d([1, 3, 5, 7], [4, 1]);
await model.fit(xs, ys, { epochs: 1 });
const prediction = model.predict(tf.tensor2d([5], [1, 1]));
prediction.print();

@tensorflow/tfjs examples

From open-source projects on GitHub

ml-kmeans

Groups numeric data with k-means clustering.

Downloads / mo
805.4K
Stars
105
Last release
7.0.1
License
MIT

Quickstart

From README.md
$ npm install ml-kmeans
import { kmeans } from 'ml-kmeans';
const result = kmeans([[1], [2], [10], [11]], 2, { seed: 42 });
console.log(result.clusters);

ml-logistic-regression

Fits logistic regression models.

Downloads / mo
769.8K
Stars
18
Last release
2.0.0
License
MIT

Quickstart

From README.md
$ npm install ml-logistic-regression ml-matrix
const { Matrix } = require('ml-matrix');
const LogisticRegression = require('ml-logistic-regression');
const model = new LogisticRegression({ numSteps: 1000, learningRate: 5e-3 });
model.train(new Matrix([[0], [1], [2], [3]]), Matrix.columnVector([0, 0, 1, 1]));
console.log(model.predict(new Matrix([[1.5]])));

ml-logistic-regression examples

From open-source projects on GitHub

@mlc-ai/web-llm

Runs hardware-accelerated language model chats in the browser.

Downloads / mo
754.5K
Stars
19.4K
Last release
0.2.89
License
Apache-2.0

Quickstart

From README.md
$ npm install @mlc-ai/web-llm
import { CreateMLCEngine } from '@mlc-ai/web-llm';
const engine = await CreateMLCEngine('Llama-3.1-8B-Instruct-q4f32_1-MLC');
const reply = await engine.chat.completions.create({ messages: [{ role: 'user', content: 'Hello' }] });
console.log(reply.choices[0].message.content);

FAQ

TensorFlow.js suits apps that build and train models in JavaScript. Transformers.js suits apps that run pretrained models in the browser. ONNX Runtime Node suits Node.js servers that execute exported ONNX models.

MediaPipe is Google's set of ready task models for image and video input. MediaPipe Tasks Vision runs those vision tasks, such as face landmark detection, in the browser.

WebLLM runs language model chats in the browser with hardware acceleration through WebGPU. It accepts requests in an OpenAI-style chat completion format.

Transformers.js runs pretrained models exported to ONNX directly in the browser. It defaults to CPU and WebAssembly, with optional WebGPU.

TensorFlow.js builds and trains models from tensor operations and layers. Transformers.js runs existing pretrained models without a training step.

For coding agents

Found your machine learning library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official