WASM ファイル形式とは?
.wasm ファイルは、スタックベースの仮想マシン用のポータブルなバイナリバイトコードである、コンパイル済み WebAssembly モジュールです。開発者は C、C++、Rust、Go、またはその他のサポートされている言語でコードを記述し、ネイティブに近い速度で動作するように .wasm にコンパイルします。ウェブ上では、このモジュールは JavaScript と並行して動作します。ブラウザはこれを取得し、システムへの直接アクセス権を持たないサンドボックス内で実行します。
WebAssembly は W3C WebAssembly Working Group によるオープン標準であり、2017年3月に最初の安定版がリリースされ、2019年12月からは W3C 勧告となっています。すべてのモジュールは 8 バイトのヘッダー 00 61 73 6D 01 00 00 00(文字列 \0asm とバージョンフィールド)で始まり、その後に型、インポート、関数、メモリ、エクスポート、およびコードの番号付きセクションが続きます。読み取り可能なテキスト形式の対応物は .wat 形式です。
セキュリティと安全性
リスク: 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.
形式の詳細
概要- 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.
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. 技術的詳細
詳細仕様| 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 |
| リリース日 | 2017 |
| 最新バージョン | WebAssembly 3.0 (2025); binary version field 0x01 |
| オープンスタンダード | はい · ロイヤリティフリー |
| 仕様書 | webassembly.github.io |
WASM の変換
コミュニティ Q&A
ユーザーからの質問まだ質問はありません。WASM ファイルについて最初の質問をしてみましょう。
よくある質問
WASM ファイルを開くにはどうすればよいですか?
wasm2wat file.wasm を使用してテキストに逆アセンブルするか、Wasmtime や Wasmer を使用してブラウザ外で実行します。WASM ファイルを編集できますか?
wasm2wat で .wat テキスト形式に変換して編集し、wat2wasm で再アセンブルしてください。本格的な変更を行う場合は、通常、元の C、C++、Rust などのソースを編集して再コンパイルします。.wasm と .wat の違いは何ですか?
.wasm はマシンが実行するコンパクトなバイナリです。.wat はそれに対応する人間が読めるテキスト形式(WebAssembly Text Format)です。これらは WABT を使用してロスレスで相互変換できます。ブラウザが .wasm ファイルを実行せずにダウンロードしてしまうのはなぜですか?
.wasm を application/wasm という MIME タイプで送信する必要があります。汎用的なタイプやテキストタイプとして配信されると、ブラウザはダウンロードしたり、ストリームコンパイルを拒否したりすることがあります。サーバーのコンテンツタイプ設定を修正してください。WASM ファイルを実行しても安全ですか?
どのようなプログラムが WASM ファイルを作成しますか?
wasm-pack を使用した Rust の wasm32 ターゲット、TinyGo/Go、Clang/LLVM などのコンパイラやツールチェーンが .wasm 出力を生成します。