Che cos'è il formato di file WASM?
Un file .wasm è un modulo WebAssembly compilato: un bytecode binario portatile per una macchina virtuale basata su stack. Gli sviluppatori scrivono codice in C, C++, Rust, Go o altri linguaggi supportati e lo compilano in .wasm affinché venga eseguito a una velocità prossima a quella nativa. Sul web, il modulo viene eseguito insieme a JavaScript; il browser lo recupera e lo esegue in una sandbox senza accesso diretto al sistema.
WebAssembly è uno standard aperto del W3C WebAssembly Working Group, stabile per la prima volta a marzo 2017 e raccomandazione W3C dal dicembre 2019. Ogni modulo inizia con un'intestazione di 8 byte 00 61 73 6D 01 00 00 00 (la stringa \0asm più un campo versione), seguita da sezioni numerate per tipi, importazioni, funzioni, memoria, esportazioni e il codice. La controparte testuale leggibile è il formato .wat.
Sicurezza e incolumità
RISCHIO: MEDIUMWebAssembly runs inside a sandbox with no direct access to the file system, network, or DOM unless the host grants it, so a module cannot escape on its own. The risk comes from what the surrounding page or runtime allows: malicious sites have used Wasm for in-browser cryptomining and for obfuscating logic that is harder to read than JavaScript. Only run standalone .wasm files from sources you trust, since a WASI runtime can be given file and network permissions.
Dettagli del formato
in sintesi- Wavefront / general 3D scene data - A few older or niche 3D and simulation tools have used .wasm for scene or mesh data, unrelated to WebAssembly.
- Application-specific save or cache files - Some standalone programs have reused the .wasm extension for internal data files; these are not WebAssembly modules and lack the \0asm header.
Programmi che aprono file WASM
.wasm served by a page and shows the disassembled module in the Debugger panel. .wasm modules automatically when a web page instantiates them; DevTools can disassemble and debug them. wasm2wat file.wasm -o file.wat to disassemble the binary into readable text; wasm-objdump prints section details. wasm2wat file.wasm; installable via Homebrew. wasm2wat file.wasm or dump sections with wasm-objdump -x file.wasm. Dettagli tecnici
specifiche approfondite| Encoding | Binary bytecode (stack-machine instructions) |
| Byte order | Little-endian for multi-byte scalars; LEB128 for integers |
| Container | Module = 8-byte header followed by a sequence of numbered sections |
| Compression | None built in; commonly served with gzip or Brotli over HTTP |
| Typical size | Tens of KB to several MB depending on the compiled program |
| Structure | Header (magic + version) then sections: Type, Import, Function, Table, Memory, Global, Export, Start, Element, Code, Data, plus optional Custom sections (names, DWARF debug info). |
| Integrity | No internal checksum; integrity handled by transport (HTTPS) or Subresource Integrity on the web |
| Platforms | Windows, macOS, Linux, Android, iOS, Web |
| Initial Release Full | March 2017 (MVP / binary format version 1) |
| Notes | Text-format counterpart is the .wat file. Source languages such as C, C++, Rust and Go compile to .wasm. Runs sandboxed in browsers and in standalone runtimes (Wasmtime, Wasmer, WasmEdge, WAMR). WASI extends it to server and CLI use. |
| Instruction Set | Virtual stack machine, structured control flow, 32/64-bit integers and floats, linear memory |
| Debug Info | Optional DWARF data and a name section carried in Custom sections |
| Rilasciato | 2017 |
| Ultima versione | WebAssembly 3.0 (2025); binary version field 0x01 |
| Standard aperto | Sì · royalty-free |
| Specifica | webassembly.github.io |
Conversioni WASM
Domande e risposte della community
chiesto dagli utentiAncora nessuna domanda - sii il primo a chiedere informazioni sui file WASM.
Domande frequenti
Come apro un file WASM?
wasm2wat file.wasm da WABT, oppure eseguilo fuori dal browser con Wasmtime o Wasmer.Posso modificare un file WASM?
.wat con wasm2wat, modificalo e poi riassemblalo con wat2wasm. Per modifiche reali, normalmente si modifica il sorgente originale C, C++ o Rust e si ricompila.Qual è la differenza tra .wasm e .wat?
.wasm è il binario compatto eseguito da una macchina; .wat è l'equivalente testo leggibile dall'uomo (WebAssembly Text Format). Possono essere convertiti l'uno nell'altro senza perdite con WABT.Perché il mio browser scarica un file .wasm invece di eseguirlo?
.wasm con il tipo MIME application/wasm. Se viene servito come tipo generico o di testo, il browser potrebbe scaricarlo o rifiutarsi di compilarlo in streaming. Correggi il content-type del server.Un file WASM è sicuro da eseguire?
Quali programmi creano file WASM?
wasm32 con wasm-pack, TinyGo/Go e Clang/LLVM producono output .wasm.