nanowasm, the tiny Wasm interpreter that does not block you
This project is still unfinished and is not meant for production use.
This project aims to provide the most minimal Wasm interpreter possible in
strictly portable ANSI C (C89/C90). It can run one or more Wasm applications
concurrently, without threading. This project requires the
Nanowasm extensions
to the WebAssembly language. A NanoWasm-compatible program can be built from
a MVP WebAssembly program with nwc.
Features
- Portable ANSI C implementation. Runs on bare metal environments.
- No dependencies other than an ANSI C (C89/C90) compiler.
- Asynchronous interface that allows to run multiple applications concurrently, without threads.
- I/O-agnostic implementation for maximum flexibility: read modules from a network, write the stack into a file, implement a MMU in software... Anything is possible!
- Suitable for resource-constrained devices, such as microcontrollers.
- No memory allocator required.
- Supports both big-endian and little-endian architectures.
Comparison chart
| Feature | nanowasm |
[wasm-micro-runtime] |
[wasm3] |
[wac] |
[toywasm] |
|---|---|---|---|---|---|
| Asynchronous interface | ✅ | ❌ | ❌ | ❌ | ❌ |
| I/O-agnostic | ✅ | ❌ | ❌ | ❌ | ❌ |
| No heap required | ✅ | ❌ | ❌ | ❌ | ❌ |
| Big-endian support | ✅ | ⚠️ | ✅ | ❌ | ✅ |
| No compiler-specific extensions | ✅ | ❌ | ❌ | ❌ | ❌ |
| C dialect | c89 |
gnu99 |
c99 |
gnu99 |
c11 |
| Public functions | 7 | 156 | 44 | N/A | N/A |
Minimal .text footprint |
49 KiB | 452 KiB | 519 KiB | N/A | N/A |
| Per-module memory usage | ~1016 bytes | N/A | N/A | N/A | N/A |
| Per-instance memory usage | ~728 bytes | N/A | N/A | N/A | N/A |
Also, see a detailed explanation behind the numbers above.
What nanowasm is not
As opposed to other interpreters, nanowasm prefers lower memory usage
rather than run-time performance. Therefore, it should not be unfairly
compared performance-wise against other interpreters.
How to build
Use the conventional process in CMake projects:
cmake -B <dir>
cmake --build <dir>
Examples
-
example/minimal.cprovides the essential minimum code required to work withnanowasmi.e., without any imports. This is only meant as a starting point for implementations, and not as a standalone program. -
example/proc_exit.cdefines the code required to support the following minimal C program built withwasi-sdk:
int main()
{
return 0;
}
License
nanowasm, a tiny WebAssembly/Wasm interpreter
Copyright (C) 2023-2025 Xavier Del Campo Romero
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at https://mozilla.org/MPL/2.0/.
Also, see LICENSE.
