LmCast :: Stay tuned in

C# now beats Rust on WASM size

Recorded: Oct. 21, 2026, 8:51 a.m.

Original Summarized

GitHub - zion-sati/NetWasm: Compile C# and .NET CIL to small standalone Wasm with WASI (AOT with built-in Runtime and Precise GC) · GitHub

Skip to content

Navigation MenuSign inAppearance settingsPlatformAI CODE CREATIONGitHub CopilotWrite better code with AIGitHub Copilot appDirect agents from issue to mergeMCP RegistryIntegrate external toolsDEVELOPER WORKFLOWSActionsAutomate any workflowCodespacesInstant dev environmentsIssuesPlan and track workCode ReviewManage code changesCode QualityEnforce quality at mergeAPPLICATION SECURITYGitHub Advanced SecurityFind and fix vulnerabilitiesCode securitySecure your code as you buildSecret protectionStop leaks before they startEXPLOREWhy GitHubDocumentationBlogChangelogMarketplaceView all featuresSolutionsBY COMPANY SIZEEnterprisesSmall and medium teamsStartupsNonprofitsBY USE CASEApp ModernizationDevSecOpsDevOpsCI/CDView all use casesBY INDUSTRYHealthcareFinancial servicesManufacturingGovernmentView all industriesView all solutionsResourcesEXPLORE BY TOPICAISoftware DevelopmentDevOpsSecurityView all topicsEXPLORE BY TYPECustomer storiesEvents & webinarsEbooks & reportsBusiness insightsGitHub SkillsSUPPORT & SERVICESDocumentationCustomer supportCommunity forumTrust centerPartnersView all resourcesOpen SourceCOMMUNITYGitHub SponsorsFund open source developersPROGRAMSSecurity LabMaintainer CommunityGitHub StarsArchive ProgramREPOSITORIESTopicsTrendingCollectionsEnterpriseENTERPRISE SOLUTIONSEnterprise platformAI-powered developer platformAVAILABLE ADD-ONSGitHub Advanced SecurityEnterprise-grade security featuresCopilot for BusinessEnterprise-grade AI featuresPremium SupportEnterprise-grade 24/7 supportPricingSearch/Sign inSign upAppearance settings

You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
You switched accounts on another tab or window. Reload to refresh your session.

Dismiss alert

zion-satiNetWasmRepository navigationCodeIssues6 (6)Pull requestsDiscussionsActionsProjectsSecurity and qualityInsightsMore items

NetWasmPublicSponsorNotificationsYou must be signed in to change notification settingsFork4 (4)Star163 (163)You must be signed in to star a repositoryAboutCompile C# and .NET CIL to small standalone Wasm with WASI (AOT with built-in Runtime and Precise GC)www.netwasm.com/TopicsaotcompilercsharpdotnetwasiwasmwebassemblyResourcesReadmeLicense, License licenses foundContributingContributingSecurity policySecurity policyActivityStars163 starsWatchers1 watchingForks4 forksReport repositorymainBranchesTagsGo to fileCodeOpen more actions menuLatest commit History253 Commits253 CommitsFolders and filesNameNameLast commit messageLast commit date.github.github  LICENSESLICENSES  compiler-qualificationcompiler-qualification  docsdocs  engeng  srcsrc  teststests  toolstools  witwit  .editorconfig.editorconfig  .gitattributes.gitattributes  .gitignore.gitignore  CLA.mdCLA.md  CONTRIBUTING.mdCONTRIBUTING.md  Directory.Build.propsDirectory.Build.props  Directory.Build.targetsDirectory.Build.targets  LICENSE-MAP.mdLICENSE-MAP.md  LICENSE.mdLICENSE.md  NetWasm.slnxNetWasm.slnx  QUICKSTART.mdQUICKSTART.md  README.mdREADME.md  SECURITY.mdSECURITY.md  SUPPORT.mdSUPPORT.md  THIRD-PARTY-NOTICES.TXTTHIRD-PARTY-NOTICES.TXT  THIRD-PARTY-NOTICES.mdTHIRD-PARTY-NOTICES.md  global.jsonglobal.json  package-lock.jsonpackage-lock.json  package.jsonpackage.json  View all filesRepository files navigationREADMEContributingLicenseLicenseSecurityMore itemsNetWasm
Independent .NET for WebAssembly and WASI.
Write C#. Deploy small, standalone Wasm.
NetWasm is an independent compiler, CoreLib, runtime and SDK that compiles C#
and .NET CIL directly to WebAssembly. It does not carry the desktop CLR, Mono,
dotnet.js or application DLLs into production.

Compile C# to WebAssembly ·
Try it in the browser ·
Install and build ·
See supported APIs ·
Read the documentation
C# now beats Rust on Wasm size
NetWasm + precise GC: 47,895 bytes
Rust 1.95.0 size-oriented profile: 53,635 bytes
For the same print-42 workload, NetWasm's result includes the runtime and
precise Compact garbage collector. Both artifacts are standalone WASI Preview 2
Components built with size-oriented settings.
10.7% smaller raw. 19.5% smaller with Brotli-11.

Toolchain
Raw Wasm
Brotli 11
Comparison role

NetWasm, Compact GC
47,895 B
13,660 B
WASI P2 Component; precise GC included

Rust 1.95.0, size profile
53,635 B
16,963 B
Matched WASI P2 Component reference

Kotlin 2.4.0 wasmWasi
79,293 B
22,655 B
P1 context; GC supplied by the host engine

TinyGo 0.39.0
93,043 B
26,931 B
P1 context; precise GC configured

Rust is the headline comparison because it uses the same workload and output
form. Kotlin/Wasm and TinyGo show the broader footprint landscape, but their
targets and runtime boundaries differ. This is a measured workload/profile
result, not a language-wide size ranking.
Exact sources, versions, settings and reproduction steps
Faster than Mono AOT
NetWasm runs our allocation and garbage-collection benchmarks
faster than Mono AOT, compiled from the same C# source and run by the same
Wasmtime:

Workload
NetWasm, NetWasmGC
Mono AOT, .NET 10
NetWasm time

Full transaction
43.9 ms
59.1 ms
26% less

Retained object graph
8.8 ms
14.2 ms
38% less

UI churn
17.6 ms
29.1 ms
40% less

These are medians of 15 runs on an Apple M1 Max under Wasmtime 49.0.3, each run
checked against desktop .NET's result. Mono AOT is Microsoft's wasi-wasm
target in its default Release configuration. NetWasmGC also takes less time than
desktop .NET 11's JIT on the first two workloads (49.9 and 9.7 ms); the JIT is
faster on UI churn (8.6 ms), and desktop NativeAOT is the fastest on all three.
Versions, settings, desktop figures and reproduction
More than Hello World
The 46.7 KiB program is the baseline, not the boundary.
C# 15 · JavaScript modules and Web Workers · static .a interop · WIT/WASI P2 ·
expression trees · HTTP/JSON/XML/Regex · reflection-free DI ·
TUnit/VSTest · wasm64 · four allocation strategies
Today NetWasm can:

build, run, publish and test projects through the ordinary dotnet CLI;
publish C# exports as typed JavaScript modules
that run in the page or in a Web Worker;
link compatible Wasm .a archives and
generate bounded C ABI marshalling;
generate C# bindings from WIT and produce standalone
WASI P2 Components;
construct and inspect expression trees without general runtime reflection;
use independently packaged LINQ, HTTP, JSON, XML, Regex, Hashing and
dependency-injection libraries;
dual-target libraries for netwasm0.1 and desktop .NET.

The profile is deliberately smaller than desktop .NET. It already supports
complete applications, portable libraries, test projects and browser modules.
Try it
Install .NET SDK 10.0.303 or newer,
then run:
dotnet new install NetWasm.Templates
dotnet new netwasm-app -n HelloNetWasm
cd HelloNetWasm
dotnet restore
dotnet run
dotnet publish -c Release -o publish/local
Run the published component with a compatible WASI Preview 2 host, such as
Wasmtime:
wasmtime run publish/local/HelloNetWasm.wasm
42

The published component is self-contained with respect to .NET. A WebAssembly
host is still required. Build with .NET; run without .NET.
Projects using C# 15 select the .NET 11 SDK; earlier language versions can stay
on .NET 10. The SDK restores its pinned Node, LLD and Binaryen tools through
NuGet, so an ordinary app does not require a separate Emscripten, Git or Python
installation. See the complete quickstart for host,
restore, Windows, browser and dual-targeting details.
How it stays small
Roslyn produces CIL. NetWasm compiles the reachable program directly to Wasm,
specializes its generics and links only the runtime support it needs. The linked
Wasm component is the program.

Closed-world compilation. Unreachable code, imports and runtime features
do not enter the artifact.
A smaller platform contract. NetWasm supports portable APIs instead of
reproducing every desktop runtime assumption.
No broad runtime reflection. Runtime type names, dynamic assembly loading
and the dynamic keyword are outside the profile.
Generated boundaries. JSON, DI, WIT and native interop use known contracts
rather than runtime discovery.
Optional data and diagnostics. Timezone data, rich stack traces and other
deployment data are included only when selected.
One collector. Only the chosen allocation strategy is linked.

This is a new .NET platform, not desktop .NET squeezed into a Wasm sandbox.
That boundary is what makes native-Wasm-sized C# possible.
How JSON and optional features affect size
Choose your allocation strategy
Compact is the default: a size-first, precise, non-moving mark-and-sweep
collector. It traces compiler-published roots and reference layouts without
conservative scanning. Its name refers to implementation size, not moving heap
compaction.

Strategy
Best fit
Raw component
Brotli 11

Compact (default)
Small applications and low-churn UI
47,895 B
13,660 B

NetWasmGC
Higher allocation throughput
50,855 B
15,053 B

Bump
Bounded, one-shot jobs
43,864 B
11,959 B

Select a strategy in the executable project's .csproj:
<PropertyGroup>
<NetWasmGarbageCollector>NetWasm</NetWasmGarbageCollector>
</PropertyGroup>
Leaving the property unset selects Compact. Libraries remain collector-neutral;
all four backends are packaged for wasm32 and wasm64. See
Choosing a garbage collector for the
tradeoffs and diagnostics.
Libraries should travel upward
A library written for the smaller NetWasm profile should also be useful on
desktop .NET, rather than trapped in a Wasm-only ecosystem.
dotnet new netwasm-lib -n MyLibrary
The template targets netwasm0.1 and net10.0, producing NuGet assets for
both platforms. This is explicit multi-targeting, not a promise that arbitrary
desktop packages work in reverse.
NetWasm.Libraries provides the
ported framework and extensions packages.
TUnit-NetWasm provides ordinary
dotnet test integration through the generic VSTest bridge.
How does this compare to conventional .NET Wasm?
For an empty-UI Blazor WebAssembly application that prints 42, with AOT,
managed trimming, IL stripping, invariant globalization and size-focused native
linking enabled:

AOT build
Uncompressed Wasm
Relative to NetWasm

NetWasm, Compact GC
47,895 B
1×

Blazor WebAssembly, .NET 10
12,276,684 B
256×

Blazor WebAssembly, .NET 11 RC1
15,289,241 B
319×

The Blazor total includes its native runtime and required Webcil assemblies;
NetWasm includes its runtime, garbage collector and WASI component. This is a
console component versus an empty-UI application, not an equivalent-framework
comparison or a claim about every .NET workload.
Exact Blazor versions, settings and reproduction
Current boundary
NetWasm is pre-1.0. Its supported profile is usable today and covered by
published qualification, but source, package, target-profile and ABI contracts
may change between minor releases.
The normal portable output is a wasm32 WASI Preview 2 Component. Raw wasm32,
raw wasm64 and JavaScript-host integration are advanced alternatives; wasm64
Components remain blocked by upstream tooling.
Runtime reflection, dynamic, runtime assembly loading and managed threading
are outside the profile. General System.IO.File/Directory/FileStream, raw
sockets and subprocess APIs are not yet implemented. Existing NuGet packages
work only when their reachable code and API dependencies fit the supported
profile.
Supported APIs and limitations ·
Documentation index
Road to 1.0
NetWasm 1.0 means a useful, documented and stable smaller platform. It does not
mean “desktop .NET, but in Wasm.” The main remaining themes are:

broader WASI Preview 2 coverage;
globalization modes and optional culture data;
expression-tree completion;
a faster incremental development loop;
a stable netwasm1.0 platform and runtime contract;
production diagnostics and broader host qualification.

New in NetWasm 0.10.0: rebuilt garbage collectors. Objects carry no
collector header, arrays are single allocations, NetWasmGC allocates by
advancing a pointer, and Compact has a new core built for size and memory.
Allocation-heavy programs run faster and use far less memory, and applications
that ship time zone data start in a fraction of the time. The Boehm collector
is removed.
Release notes
In progress: broader compatibility with existing .NET Standard
2.1 library binaries and NuGet assets. The target is to consume libraries
unchanged when their reachable code fits the NetWasm profile, without carrying
unused unsupported paths into the application.
This does not turn NetWasm into desktop .NET. Reachable general runtime
reflection, dynamic, runtime assembly loading, managed threading, unsupported
host APIs and named-culture globalization remain outside the initial
compatibility slice and fail at compile time.
Read the full 1.0 roadmap
Packages

Compiler, SDK, runtime and hosting packages
NetWasm.Compiler.Browser ·
NetWasm.Compiler.Tasks ·
NetWasm.Hosting ·
NetWasm.Hosting.Build ·
NetWasm.Ref ·
NetWasm.Runtime.Pack ·
NetWasm.Runtime.Wasm32 ·
NetWasm.Runtime.Wasm64 ·
NetWasm.Sdk ·
NetWasm.Templates ·
NetWasm.Testing.VSTest ·
NetWasm.Toolchain ·
NetWasm.Wit.Bindings.Tool
Ported-library packages ·
TUnit packages

License
CoreLib, runtime libraries, templates and generated support code are MIT,
subject to preserved upstream notices. The compiler and developer tooling use
the NetWasm Community License 1.0.
The Compact and NetWasmGC collectors are Apache-2.0.
The Community License is free for qualifying individuals, education,
open-source work, evaluation, and organizations with fewer than 250 employees
and less than USD 10,000,000 in annual revenue. Matching
GitHub Sponsors tiers grant limited
internal commercial use; OEM and Commercial Offering use require a separate
agreement. Generated applications may use their authors' chosen licenses.
There is no sign-in, activation, telemetry or technical enforcement.
Licensing guide ·
Third-party notices ·
Commercial licensing: zionsatidev@gmail.com
Bring a workload
Start with Console.WriteLine(42), then try the smallest real workload where
deployment size, sandboxing or portability matters. If something is missing,
open an issue. Concrete workloads
are how the 1.0 support boundary gets decided.
AboutCompile C# and .NET CIL to small standalone Wasm with WASI (AOT with built-in Runtime and Precise GC)www.netwasm.com/TopicsaotcompilercsharpdotnetwasiwasmwebassemblyResourcesReadmeLicense, License licenses foundContributingContributingSecurity policySecurity policyActivityStars163 starsWatchers1 watchingForks4 forksReport repositoryReleasesSponsor this projectPackagesContributorsLanguages

Footer

© 2026 GitHub, Inc.

Footer navigation

Terms

Privacy

Security

Status

Community

Docs

Contact

Manage cookies

Do not share my personal information

You can’t perform that action at this time.

WasmGC garbage collectors are licensed under the Apache 2.0 license. Commercial licensing options are available through contact. The project does not include sign-in, activation, telemetry, or technical enforcement mechanisms.

This summary encapsulates the core aspects of the NetWasm project, authored by zion-sati, which stands as a pioneering effort in compiling C sharp and .NET CIL into compact, standalone WebAssembly artifacts with a built-in runtime and precise garbage collector.

NetWasm represents an independent platform that diverges from traditional .NET environments by eliminating the need for desktop CLR, Mono, or application DLLs within the final WebAssembly output. It harnesses the WASI specification to deliver a self-contained runtime and a precise garbage collector directly into the compiled code, thereby enabling the creation of WebAssembly applications that are significantly smaller and more efficient. This approach fundamentally challenges the conventional size constraints of .NET for WebAssembly.

A central achievement of NetWasm is its capacity to produce exceptionally small WebAssembly components. For a workload that merely prints the number 42, the NetWasm compilation utilizing its precise Compact garbage collector results in a raw WebAssembly file of 47,895 bytes, which compresses to 13,660 bytes after Brotli 11 compression. In direct comparison, Rust's size-oriented profile for the same workload totals 53,635 bytes raw, or 16,963 bytes compressed, leading to a 10.7% reduction in raw size and a 19.5% reduction with compression. These figures underscore the effectiveness of NetWasm's closed-world compilation, which excludes unreachable code, imports, and unnecessary runtime features, combined with a specialized, size-optimized garbage collector.

Beyond raw size, NetWasm delivers superior performance in benchmarking. Under identical conditions with Wasmtime 49.0.3 on an Apple M1 Max, NetWasm runs allocation and garbage-collection benchmarks 26% faster for a full transaction, 38% faster for a retained object graph, and 40% faster for UI churn compared to Mono AOT compiled from the same C sharp source. Additionally, NetWasmGC, which prioritizes allocation throughput, is faster than desktop .NET 11's JIT on the first two benchmark categories, while desktop NativeAOT remains the fastest overall. These benchmarks demonstrate that the built-in runtime and precise garbage collector are not only smaller but also more responsive than traditional AOT alternatives.

The small footprint of NetWasm arises from a deliberate design philosophy that compiles only the reachable program directly to WebAssembly, specializing generics and linking only the runtime support necessary for the specific workload. This closed-world compilation ensures that unreachable code, unnecessary imports, and runtime features absent from the application are excluded from the artifact. NetWasm adopts a smaller platform contract by offering portable APIs rather than replicating every desktop runtime assumption. It also avoids broad runtime reflection, which would otherwise inflate the artifact, and relies on known contracts for interop through JSON, dependency injection, WIT (WebAssembly Interface Type), and native linking. Optional data and diagnostics, such as timezone data and detailed stack traces, are included only when explicitly selected, further minimizing size. The use of a single, chosen garbage collector strategy adds to this efficiency.

NetWasm provides three garbage collector strategies, selectable via the project configuration property <NetWasmGarbageCollector>. The default Compact collector is a size-first, precise, non-moving mark-and-sweep implementation that traces compiler-published roots and reference layouts without conservative scanning, making it ideal for small applications and low-churn user interfaces. The NetWasmGC collector prioritizes higher allocation throughput, albeit at a slightly larger size. The Bump collector is designed for bounded, one-shot jobs, achieving the smallest raw component size. Libraries remain collector-neutral, with all four backends packaged for both wasm32 and wasm64 targets. The choice of collector is a deliberate trade-off between size, memory, and allocation performance.

NetWasm supports a comprehensive set of modern C sharp features, including C sharp 15 language features, JavaScript modules and Web Workers, static .a interop, WIT/WASI P2 component generation, expression trees, HTTP, JSON, XML, Regex, hashing, and reflection-free dependency injection. It enables building, running, publishing, and testing projects through the standard dotnet CLI, producing typed JavaScript modules that can execute in the browser or Web Workers, and generating bounded C ABI marshalling for native interop. The project provides dual-target libraries for both the NetWasm profile (netwasm0.1) and desktop .NET (net10.0), with accompanying packages such as NetWasm.Libraries, TUnit-NetWasm, and related tooling.

To use NetWasm, developers install the .NET SDK 10.0.303 or newer, then install the NetWasm templates using dotnet new install NetWasm.Templates. A sample project can be created with dotnet new netwasm-app -n HelloNetWasm, restored, and run. For deployment, dotnet publish -c Release -o publish/local is executed, and the resulting standalone WASI Preview 2 component is run with a compatible host such as Wasmtime via wasmtime run publish/local/HelloNetWasm.wasm. The published component is self-contained with respect to .NET, meaning that only a WebAssembly host is required at runtime, not the full .NET runtime. Projects using C sharp 15 require the .NET 11 SDK, while earlier language versions can remain on .NET 10.

Despite its capabilities, NetWasm is currently in a pre-1.0 stage, meaning its supported profile is usable today but may undergo changes between minor releases as the project progresses toward a stable 1.0 release. The normal output format is a wasm32 WASI Preview 2 Component, though raw wasm32, raw wasm64, and JavaScript-host integration are advanced alternatives; wasm64 Components remain blocked by upstream tooling. Several APIs are outside the current profile, including runtime reflection, dynamic keyword usage, runtime assembly loading, managed threading, general System.IO.File/Directory/FileStream, raw sockets, and subprocess APIs. Existing NuGet packages are compatible only when their reachable code and API dependencies fit within the supported profile, and unsupported code paths fail at compile time. These boundaries are intentional, reflecting the effort to produce a lean, specialized platform rather than a full-featured desktop runtime replacement.

The road to 1.0 for NetWasm focuses on achieving a useful, documented, and stable smaller platform, with remaining themes including broader WASI Preview 2 coverage, globalization modes and optional culture data, expression-tree completion, a faster incremental development loop, a stable netwasm1.0 platform and runtime contract, and production diagnostics with broader host qualification. In version 0.10.0, significant improvements were made to the garbage collectors: objects now carry no collector header, arrays are single allocations, NetWasmGC allocates by advancing a pointer, and the Compact collector features a new core built for size and memory. These changes result in faster allocation for allocation-heavy programs, reduced memory usage, and faster startup times even when applications include time zone data. The Boehm collector has been removed from the toolchain.

NetWasm is distributed through a comprehensive set of packages, including compiler, SDK, runtime, hosting, testing, toolchain, and WIT bindings packages, as well as ported-library and TUnit packages. The licensing model is multifaceted: CoreLib, runtime libraries, templates, and generated support code are under the MIT license, subject to preserved upstream notices. The compiler and developer tooling use the NetWasm Community License 1.0, which is free for qualifying individuals, education, open-source work, and organizations with fewer than 250 employees and less than USD 10,000,000 in annual revenue. The Compact and NetWasmGC garbage collectors are licensed under the Apache 2.0 license. Commercial licensing options are available through contact. The project does not include sign-in, activation, telemetry, or technical enforcement mechanisms.