WebNN Has a Free API You've Never Heard Of
WebNN (Web Neural Network API) is a new browser API that gives JavaScript direct access to hardware-accelerated machine learning. It runs on NPUs, GPUs, and CPUs — and it's already available in Chr...

Source: DEV Community
WebNN (Web Neural Network API) is a new browser API that gives JavaScript direct access to hardware-accelerated machine learning. It runs on NPUs, GPUs, and CPUs — and it's already available in Chrome 124+. What Makes WebNN Different? Hardware acceleration — uses NPU/GPU/CPU automatically Browser-native — no WASM, no ONNX runtime, just a web API Privacy-first — all inference runs locally, no server needed Standardized — W3C specification, supported by Intel, Google, Microsoft The Hidden API: Neural Network Builder WebNN provides a graph-based API for building and running ML models: const context = await navigator.ml.createContext({deviceType: 'gpu'}); const builder = new MLGraphBuilder(context); // Build a simple neural network const input = builder.input('input', {dataType: 'float32', shape: [1, 784]}); // Hidden layer const weights1 = builder.constant( {dataType: 'float32', shape: [784, 128]}, new Float32Array(784 * 128) // pretrained weights ); const bias1 = builder.constant( {dataT