Visit https://ibelem.github.io/webnn-code-generator/
The WebNN Code Generator offers a user-friendly web interface for generating WebNN-compatible JavaScript code. The tool supports various model formats (ONNX, TensorFlow Lite, or others) and generates optimized code for browser-based machine learning inference.
All model conversion and code generation processes execute entirely within your browser, ensuring your intellectual property remains private and secure as no model data is transmitted to or stored on cloud servers.
The conversion process involves two complementary tools:
- WebNN Netron - Extracts model structure and weights
 - WebNN Code Generator - Generates WebNN JavaScript code
 
- Navigate to WebNN Netron
 - Click the "Open Model..." button
 - Select your model file (
.onnx,.tflite, or other supported formats) - Once loaded, download the required files:
- Click "Graph and Weights" button → Download 
graph.json,weights_nchw.binandweights_nhwc.bin 
 - Click "Graph and Weights" button → Download 
 
- Open WebNN Code Generator
 - Upload the extracted files:
- Choose "Graph" → Select 
graph.json - Choose "Weights" → Select 
weights_nchw.binandweights_nhwc.bin 
 - Choose "Graph" → Select 
 
If your model contains symbolic dimensions, you'll see a "Set free dimension overrides" section:
- Enter specific values for each dynamic dimension
 - This resolves variables like batch size or input dimensions to concrete values
 - See symbolic dimensions documentation for details
 
- Click "Generate WebNN Code"
 - Click "Download Code Files" to receive:
- Generated JavaScript file with WebNN implementation
 index.htmltest file for validation
 - Put the 
weights_nchw.binandweights_nhwc.bindownloaded from WebNN Netron together with.jsandindex.htmlin the same folder 
WebNN requires a secure context to function. Valid environments include:
https://URLshttp://localhostorhttp://127.0.0.1- Local development servers
 
Start a local HTTP server to test your generated code:
# Install http-server if needed
npm install -g http-server
# Start server in your project directory
http-server
# Navigate to http://localhost:8080 in your browserOpen the generated index.html file in your browser to validate the conversion.