Vad är filformatet WASM?
En .wasm-fil är en kompilerad WebAssembly-modul: portabel binär bytecode för en stackbaserad virtuell maskin. Utvecklare skriver kod i C, C++, Rust, Go eller ett annat språk som stöds och kompilerar den till .wasm så att den körs i nära infödd hastighet. På webben körs modulen tillsammans med JavaScript; webbläsaren hämtar den och kör den i en sandlåda utan direkt åtkomst till ditt system.
WebAssembly är en öppen standard från W3C WebAssembly Working Group, först stabil i mars 2017 och en W3C-rekommendation sedan december 2019. Varje modul börjar med en 8-byte header 00 61 73 6D 01 00 00 00 (strängen \0asm plus ett versionsfält), följt av numrerade sektioner för typer, importer, funktioner, minne, exporter och koden. Den läsbara textmotsvarigheten är formatet .wat.
Säkerhet & trygghet
RISK: 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.
Formatdetaljer
i ett nötskal- 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.
Program som öppnar WASM-filer
.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. .wasm module with wasmer run file.wasm, including WASI programs. wasm2wat file.wasm; installable via Homebrew. wasm2wat file.wasm or dump sections with wasm-objdump -x file.wasm. Tekniska detaljer
djup specifikation| 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 |
| Släppt | 2017 |
| Senaste version | WebAssembly 3.0 (2025); binary version field 0x01 |
| Öppen standard | Ja · royaltyfri |
| Specifikation | webassembly.github.io |
WASM-konverteringar
Frågor & svar
frågat av användareInga frågor än - bli den första att fråga om WASM-filer.
Vanliga frågor
Hur öppnar jag en WASM-fil?
wasm2wat file.wasm från WABT, eller kör den utanför en webbläsare med Wasmtime eller Wasmer.Kan jag redigera en WASM-fil?
.wat med wasm2wat, redigera den och sätt sedan ihop den igen med wat2wasm. För riktiga ändringar redigerar du normalt den ursprungliga källkoden i C, C++ eller Rust och kompilerar om.Vad är skillnaden mellan .wasm och .wat?
.wasm är den kompakta binärfilen som en maskin exekverar; .wat är motsvarande mänskligt läsbara text (WebAssembly Text Format). De kan konverteras fram och tillbaka förlustfritt med WABT.Varför laddar min webbläsare ner en .wasm-fil istället för att köra den?
.wasm med MIME-typen application/wasm. Om den skickas som en generisk typ eller texttyp kan webbläsaren ladda ner den eller vägra att ström-kompilera den. Åtgärda serverns innehållstyp.Är en WASM-fil säker att köra?
Vilka program skapar WASM-filer?
wasm32-mål med wasm-pack, TinyGo/Go och Clang/LLVM producerar .wasm-utdata.