# WebNN API
The Web Neural Network API — a W3C specification for running neural network models directly in web browsers with hardware acceleration. Foundation layer of the [[WebMachineLearning]] ecosystem; higher-level APIs (Prompt API, Writing Assistance APIs) build on top of it.
Spec repo: https://github.com/webmachinelearning/webnn
## What it does
WebNN exposes browser-level access to the device's ML hardware (GPU, NPU) via a JavaScript API. Developers can:
- Build, compile, and execute computation graphs for neural networks
- Leverage hardware-specific optimizations without writing platform-specific code
- Run inference on models without a server or cloud API
## Design Goals
- **Hardware agnostic**: single API works across GPU, NPU, CPU backends
- **Cross-browser**: standardized contract; one implementation for all browsers
- **Performance**: native hardware acceleration, not a pure JS polyfill
- **Low-level**: intentionally primitive — higher-level APIs compose on top of it
## Relationship to Other APIs
- **[[Prompt API]]** — uses WebNN or OS model interfaces under the hood
- **[[Writing Assistance APIs]]** — Summarizer, Writer, Rewriter compose on WebNN
- WebAssembly (WASM): complementary; WebNN focuses on ML-specific hardware paths
## Status
W3C Candidate Recommendation. Shipping in Chrome and Edge. Under development in other browsers.
## References
- https://github.com/webmachinelearning/webnn
- https://www.w3.org/TR/webnn/
## Related
- [[WebMachineLearning]]
- [[Prompt API]]
- [[Writing Assistance APIs]]
- [[Neural Networks (NNs)]]
- [[Machine Learning (ML)]]
- [[AI Inference]]
- [[On-Device Machine Learning]]
- [[Browser-Provided Language Models]]
- [[WebGPU]]
- [[Web Assembly (WASM)]]
- [[ONNX]]
- [[ONNX Runtime Web]]
- [[Transformers.js]]
- [[Neural Processing Unit (NPU)]]
- [[Edge AI]]