O que é o formato de ficheiro WASM?
Um arquivo .wasm é um módulo WebAssembly compilado: bytecode binário portátil para uma máquina virtual baseada em pilha. Os desenvolvedores escrevem código em C, C++, Rust, Go ou outra linguagem suportada e o compilam para .wasm para que ele seja executado em uma velocidade próxima à nativa. Na web, o módulo é executado junto com o JavaScript; o navegador o busca e o executa em um sandbox sem acesso direto ao seu sistema.
O WebAssembly é um padrão aberto do W3C WebAssembly Working Group, estável pela primeira vez em março de 2017 e uma Recomendação do W3C desde dezembro de 2019. Cada módulo começa com o cabeçalho de 8 bytes 00 61 73 6D 01 00 00 00 (a string \0asm mais um campo de versão), seguido por seções numeradas para tipos, importações, funções, memória, exportações e o código. A contraparte de texto legível é o formato .wat.
Segurança e proteção
RISCO: 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.
Detalhes do formato
em resumo- 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.
Programas que abrem arquivos 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. .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. Detalhes técnicos
especificação profunda| 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 |
| Lançado | 2017 |
| Versão mais recente | WebAssembly 3.0 (2025); binary version field 0x01 |
| Padrão aberto | Sim · livre de royalties |
| Especificação | webassembly.github.io |
Conversões de WASM
Perguntas e Respostas da Comunidade
perguntado por usuáriosAinda não há perguntas - seja o primeiro a perguntar sobre arquivos WASM.
Perguntas frequentes
Como faço para abrir um arquivo WASM?
wasm2wat file.wasm do WABT, ou execute-o fora de um navegador com Wasmtime ou Wasmer.Posso editar um arquivo WASM?
.wat com wasm2wat, edite-o e, em seguida, remonte-o com wat2wasm. Para mudanças reais, você normalmente edita o código-fonte original em C, C++ ou Rust e recompila.Qual é a diferença entre .wasm e .wat?
.wasm é o binário compacto que uma máquina executa; .wat é o texto equivalente legível por humanos (WebAssembly Text Format). Eles são convertidos de um para o outro sem perdas com o WABT.Por que meu navegador está baixando um arquivo .wasm em vez de executá-lo?
.wasm com o tipo MIME application/wasm. Se for servido como um tipo genérico ou de texto, o navegador pode baixá-lo ou recusar a compilação via stream. Corrija o tipo de conteúdo (content type) do servidor.Um arquivo WASM é seguro para executar?
Quais programas criam arquivos WASM?
wasm32 com wasm-pack, TinyGo/Go e Clang/LLVM produzem saída .wasm.