Rust to WebAssembly

Convert your Rust code to WebAssembly for high-performance web applications

Upload Your Rust Files

Drag and drop your Rust source files or ZIP archives to compile them to WebAssembly and generate the necessary JavaScript interface files.

Drag and drop your Rust files or ZIP archives here or click to browse

Only .rs and .zip files are accepted

Processing... 0%

Conversion Results

Files
Preview
Documentation

File Preview

Select a file to preview its content

Generated Documentation

Note: Convert and copy the above files to a web server to run this demo. Simply opening the HTML file directly from your local machine will not work—it needs to be served over HTTP to properly load the WebAssembly binary. (Yes, we know the impatience!)

This demo allows you to interact with functions exported from your compiled Rust code (you can safely ignore the initSync(), init() and main() functions [generally main() does not return anything]).

The only required file is the .wasm binary file. The JavaScript interface file is included simply to keep the main program clean by offloading additional logic so it may be optional —though in our case, it's necessary, since our sample HTML file doesn't include that additional logic. The sample HTML file serves purely to initially test the .wasm file through the JavaScript interface file. All other files can be safely ignored. For your application initially use the .wasm and the JavaScript interface file, later you may move the logic around and may not even need the JavaScript interface file.

Important: The following crates [there may be lot more, especially those that depend on these] are incompatible with WebAssembly due to their reliance on system-level features like threading, file system access, or platform-specific APIs. Unless a workaround is found, you should avoid using these crates in your WebAssembly project:

These crates rely on low-level, OS-dependent functionality such as threading, file system manipulation, and direct access to hardware or system APIs, which are not supported in the WebAssembly environment. WASM operates in a secure, sandboxed context, and therefore, these operations must be avoided for compatibility.

FYI: Messages appearing in the .wat (WebAssembly Text Format) file—such as "Lazy instance has previously been poisoned\00..."—are not errors. They are diagnostic strings and runtime metadata automatically embedded by Rust's tooling (like wasm-bindgen) to support features like:

These messages typically appear when compiling in debug mode or using standard library features. This project includes two WebAssembly binaries: one compiled directly from Rust, and another generated from the equivalent .wat file, to verify accuracy. You may use either for testing.

Tip: When replacing files on the web server, be mindful of caching issues—especially when using the same filenames repeatedly. In such cases, press Ctrl + click the browser's refresh button to force a reload and avoid stale content.