brainjs/brain.js — explained in plain English
Analysis updated 2026-06-24 · repo last pushed 2024-09-26
Train a small feed-forward neural network in a browser tab and run predictions client-side.
Forecast a time series with an LSTM that runs inside a Node.js backend.
Classify short text snippets or simple images without leaving JavaScript or calling a Python service.
Build an in-browser teaching demo that shows training curves and predictions live as users tweak data.
| brainjs/brain.js | airbnb/react-sketchapp | sindresorhus/got | |
|---|---|---|---|
| Stars | 14,856 | 14,879 | 14,903 |
| Language | TypeScript | TypeScript | TypeScript |
| Last pushed | 2024-09-26 | — | — |
| Maintenance | Stale | — | — |
| Setup difficulty | easy | moderate | easy |
| Complexity | 2/5 | 3/5 | 2/5 |
| Audience | developer | designer | developer |
Figures from each repo's GitHub metadata at analysis time.
GPU mode needs the headless-gl native module, prebuilt binaries usually work but a source build needs GLEW and libxi-dev on Linux.
brain.js is a JavaScript library for building and training neural networks, the kind of model that learns patterns from example data. It can run in a normal Node.js server or directly in a web browser, and it can use the graphics card on the machine to speed things up where one is available. The project is a continuation of an older library called harthur/brain that is no longer maintained. The README emphasises that you do not need to leave the JavaScript world to use it. You install it with npm install brain.js, or drop in a script tag from a CDN like unpkg, and you have access to several network types: feed-forward NeuralNetwork, recurrent RNN, LSTM, GRU, time-step variants of those for sequence forecasting, and autoencoders. A short XOR example in the README shows the basic shape of the API. You create a network with a config object that sets things like the number of hidden layer neurons and the activation function, then call net.train with an array of input and output pairs, and net.run to get a prediction for a new input. For GPU acceleration the library depends on a native module called headless-gl. The README explains that prebuilt binaries usually work, but if they fail to download you may need to build from source, which on Linux means installing build-essential, GLEW, libxi-dev, and pkg-config. The full README is longer than what was shown.
brain.js is a JavaScript neural network library for Node and the browser, with feed-forward, RNN, LSTM, and GRU types and optional GPU acceleration.
Mainly TypeScript. The stack also includes JavaScript, TypeScript, Node.js.
Stale — no commits in 1-2 years (last push 2024-09-26).
Setup difficulty is rated easy, with roughly 5min to a first successful run.
Mainly developer.
This repo across BitVibe Labs
Verify against the repo before relying on details.