Co to jest format pliku WASM?
Plik .wasm to skompilowany moduł WebAssembly: przenośny binarny kod bajtowy dla maszyny wirtualnej opartej na stosie. Programiści piszą kod w językach C, C++, Rust, Go lub innych obsługiwanych językach i kompilują go do formatu .wasm, aby działał z prędkością bliską natywnej. W sieci moduł działa obok JavaScript; przeglądarka pobiera go i wykonuje w piaskownicy (sandbox) bez bezpośredniego dostępu do systemu użytkownika.
WebAssembly to otwarty standard grupy roboczej W3C WebAssembly, który stał się stabilny w marcu 2017 r., a od grudnia 2019 r. jest rekomendacją W3C. Każdy moduł zaczyna się od 8-bajtowego nagłówka 00 61 73 6D 01 00 00 00 (ciąg \0asm plus pole wersji), po którym następują ponumerowane sekcje dla typów, importów, funkcji, pamięci, eksportów i kodu. Czytelnym tekstowym odpowiednikiem jest format .wat.
Bezpieczeństwo
RYZYKO: 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.
Szczegóły formatu
w pigułce- 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.
Programy otwierające pliki 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. Szczegóły techniczne
specyfikacja| 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 |
| Wydano | 2017 |
| Najnowsza wersja | WebAssembly 3.0 (2025); binary version field 0x01 |
| Otwarty standard | Tak · bezpłatny (royalty-free) |
| Specyfikacja | webassembly.github.io |
Konwersje WASM
Pytania i odpowiedzi społeczności
pytania użytkownikówBrak pytań - bądź pierwszą osobą, która zapyta o pliki WASM.
Najczęściej zadawane pytania
Jak otworzyć plik WASM?
wasm2wat plik.wasm z pakietu WABT lub uruchom poza przeglądarką za pomocą Wasmtime lub Wasmer.Czy mogę edytować plik WASM?
.wat za pomocą wasm2wat, wyedytuj go, a następnie złóż ponownie za pomocą wat2wasm. W przypadku istotnych zmian zazwyczaj edytuje się oryginalny kod źródłowy C, C++ lub Rust i kompiluje go ponownie.Jaka jest różnica między .wasm a .wat?
.wasm to kompaktowy plik binarny wykonywany przez maszynę; .wat to jego odpowiednik w formacie tekstowym czytelnym dla człowieka (WebAssembly Text Format). Można je konwertować między sobą bezstratnie za pomocą WABT.Dlaczego moja przeglądarka pobiera plik .wasm zamiast go uruchamiać?
.wasm z typem MIME application/wasm. Jeśli jest on serwowany jako typ ogólny lub tekstowy, przeglądarka może go pobrać lub odmówić kompilacji strumieniowej. Należy poprawić typ zawartości (content type) na serwerze.Czy plik WASM jest bezpieczny do uruchomienia?
Jakie programy tworzą pliki WASM?
wasm32 w Rust z wasm-pack, TinyGo/Go oraz Clang/LLVM, generują dane wyjściowe w formacie .wasm.