keras-js brings the Keras 3 API to the web

Build, train and fine-tune neural networks in your browser, on WebGPU and WebAssembly. Same layers, same compile() and fit(), and the same .keras files as Python.

Add keras-js to your project

Runs on jax-js. Works with and in .

Training in this page

starting…
step0
loss–
accuracy–

Keras, without the Python

keras-js is the Keras 3 API written in TypeScript on top of jax-js, the way Keras 3 runs on JAX. A model is a pure function of its weights, so every training step is differentiated with grad and compiled with jit into fused WebGPU or Wasm kernels.

  • Runs entirely client-side: Chrome, Edge, Safari, Firefox, and Node.
  • Matches Python Keras numerically: predictions and optimizer steps agree to 1e-4 on a parity suite.
  • Reads and writes real .keras files. Train in Python and fine-tune here, or train here and keras.saving.load_model() it in Python.
  • Sequential, functional and subclassed models; 46 layers, 6 optimizers, callbacks.
  • Masking, recurrent states, sample and class weights, and optimizer checkpoints behave as in Keras, so training resumes on either side.

The goal is that a Keras user can take a model to the browser without learning a new framework, and that models trained on a user's own device never have to leave it.

Try it out!

This is a live editor; the code runs in your browser.

Console

          

Keras 3, layer for layer

The same names, arguments and weight layout as keras.layers.

Core

Input · Dense · Activation · Embedding · Masking · Dropout · GaussianNoise · Rescaling · Lambda · Identity

Convolution

Conv1D · Conv2D · Conv3D · DepthwiseConv2D · SeparableConv2D · Conv2DTranspose

Pooling

MaxPooling1D/2D · AveragePooling1D/2D · GlobalAveragePooling1D/2D · GlobalMaxPooling1D/2D

Recurrent and attention

LSTM · GRU · SimpleRNN · Bidirectional (masks, returnState, initialState) · MultiHeadAttention

Normalization and shape

BatchNormalization · LayerNormalization · Flatten · Reshape · Permute · RepeatVector · ZeroPadding2D · UpSampling2D

Merging

Add · Subtract · Multiply · Average · Maximum · Minimum · Concatenate

Learn more