{"id":18797942,"url":"https://github.com/ewasm/wasm-json-toolkit","last_synced_at":"2026-02-23T22:14:47.138Z","repository":{"id":91809580,"uuid":"75652712","full_name":"ewasm/wasm-json-toolkit","owner":"ewasm","description":"[ORPHANED] A small toolkit for converting wasm binaries into json and back.","archived":false,"fork":false,"pushed_at":"2024-04-22T12:34:29.000Z","size":798,"stargazers_count":32,"open_issues_count":11,"forks_count":20,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-23T23:37:31.718Z","etag":null,"topics":["wasm","webassembly"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ewasm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-05T18:09:48.000Z","updated_at":"2024-07-03T13:33:38.000Z","dependencies_parsed_at":"2024-06-19T05:35:11.239Z","dependency_job_id":null,"html_url":"https://github.com/ewasm/wasm-json-toolkit","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ewasm%2Fwasm-json-toolkit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ewasm%2Fwasm-json-toolkit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ewasm%2Fwasm-json-toolkit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ewasm%2Fwasm-json-toolkit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ewasm","download_url":"https://codeload.github.com/ewasm/wasm-json-toolkit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248743953,"owners_count":21154775,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["wasm","webassembly"],"created_at":"2024-11-07T22:10:03.863Z","updated_at":"2025-10-24T22:03:50.727Z","avatar_url":"https://github.com/ewasm.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SYNOPSIS \n[![NPM Package](https://img.shields.io/npm/v/wasm-json-toolkit.svg?style=flat-square)](https://www.npmjs.org/package/wasm-json-toolkit)\n[![Build Status](https://img.shields.io/travis/ewasm/wasm-json-toolkit.svg?branch=master\u0026style=flat-square)](https://travis-ci.org/ewasm/wasm-json-toolkit)\n[![Coverage Status](https://img.shields.io/coveralls/ewasm/wasm-json-toolkit.svg?style=flat-square)](https://coveralls.io/r/ewasm/wasm-json-toolkit)\n\n[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)  \n\nA small toolkit for converting wasm binaries into json and back. \n\n# INSTALL\n`npm install wasm-json-toolkit`\n\n# USAGE\n```javascript\nconst fs = require('fs')\nconst wasm2json = require('wasm-json-toolkit').wasm2json\n\nconst wasm = fs.readFileSync('./test.wasm')\nconst json = wasm2json(wasm)\n\nconsole.log(JSON.stringify(json, null, 2))\n```\n\n# CLI\nInstall `-g` global for cli usage.\n\n`wasm2json [FILE]` given a file containing a wasm module produces a json representation  \n`json2wasm [FILE]` given a file containing a json representation produces a wasm module  \n\n# API\n# wasm2json\n\nconverts a wasm binary into a json representation\n\n**Parameters**\n\n-  `Buffer` - The Webassembly Binary\n-  `filter` - `Set` containing the name of sections to parse. If no filter is given all sections will be parsed\n\nReturns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** \n\n# json2wasm\n\nconverts a json representation to a wasm binary\n\n**Parameters**\n\n-   `Object`  \n\nReturns **[Buffer](https://nodejs.org/api/buffer.html)** \n\n# text2json\n\nconverts text to json. The only text accepted is a simple list of opcode name and immediates\n\n**Parameters**\n\n-   `String`  \n\n**Examples**\n\n```javascript\nconst codeStr = `\ni64.const 1\ni64.const 2\ni64.add\n`\nconst json = text2json(codeStr)\n```\n\nReturns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** \n\n# iterator\n\n[iterator.js:12-58](https://github.com/ewasm/wasm-json-toolkit/blob/e9fdd9498451b39b84c1167e78dc4aad03b055bd/iterator.js#L12-L58 \"Source code on GitHub\")\n\nThe Module Iterator allows for iteration over a webassembly module's sections.\nA section is wrapped in a section class. A section class instance allows you\nappend entries to a given section\n\n**Examples**\n\n```javascript\nconst it = new Iterator(wasm)\nfor (const section of it) {\n  console.log(section.type)\n  const json = section.toJSON()\n}\n```\n\n## wasm\n\n[iterator.js:26-32](https://github.com/ewasm/wasm-json-toolkit/blob/e9fdd9498451b39b84c1167e78dc4aad03b055bd/iterator.js#L26-L32 \"Source code on GitHub\")\n\nif the orignal wasm module was modified then this will return the modified\nwasm module\n\n## iterator\n\n[iterator.js:38-52](https://github.com/ewasm/wasm-json-toolkit/blob/e9fdd9498451b39b84c1167e78dc4aad03b055bd/iterator.js#L38-L52 \"Source code on GitHub\")\n\nIterates through the module's sections\nreturn {Iterator.\u003cSection\u003e}\n\n# Section\n\n[iterator.js:64-110](https://github.com/ewasm/wasm-json-toolkit/blob/e9fdd9498451b39b84c1167e78dc4aad03b055bd/iterator.js#L64-L110 \"Source code on GitHub\")\n\nThe section class is always internal created by the Module class. And return\nthrough the Module's iternator\n\n\n## toJSON\n\n[iterator.js:83-85](https://github.com/ewasm/wasm-json-toolkit/blob/e9fdd9498451b39b84c1167e78dc4aad03b055bd/iterator.js#L83-L85 \"Source code on GitHub\")\n\nParses the section and return the JSON repesentation of it\nreturns {Object}\n\n## appendEntries\n\n[iterator.js:92-109](https://github.com/ewasm/wasm-json-toolkit/blob/e9fdd9498451b39b84c1167e78dc4aad03b055bd/iterator.js#L92-L109 \"Source code on GitHub\")\n\nAppends an array of entries to this section. NOTE: this will modify the\nparent wasm module.\n\n**Parameters**\n\n-   `entries` **Arrayy\u0026lt;[Buffer](https://nodejs.org/api/buffer.html)\u003e** \n\n\n## exammple json output\n\nwast\n```\n(module\n  (func $addTwo (param i32 i32) (result i32)\n    (i32.add\n      (get_local 0)\n      (get_local 1)))\n  (export \"addTwo\" (func $addTwo)))\n```\n\nwasm\n```\n0x010661646454776f00000a09010700200020016a0b\n```\n\njson\n```\n[\n  {\n    \"name\": \"preramble\",\n    \"magic\": [0,97,115,109],\n    \"version\": [13,0,0,0]\n  },\n  {\n    \"name\": \"type\",\n    \"entries\": [\n      {\n        \"form\": \"func\",\n        \"params\": [\"i32\",\"i32\"],\n        \"return_type\": \"i32\"\n      }\n    ]\n  },\n  {\n    \"name\": \"function\",\n    \"entries\": [0]\n  },\n  {\n    \"name\": \"export\",\n    \"entries\": [\n      {\n        \"field_str\": \"addTwo\",\n        \"kind\": \"Function\",\n        \"index\": 0\n      }\n    ]\n  },\n  {\n    \"name\": \"code\",\n    \"entries\": [\n      {\n        \"locals\": [],\n        \"code\": [\n          {\n            \"name\": \"get_local\",\n            \"immediaties\": \"0\"\n          },\n          {\n            \"name\": \"get_local\",\n            \"immediaties\": \"1\"\n          },\n          {\n            \"return_type\": \"i32\",\n            \"name\": \"add\"\n          },\n          {\n            \"name\": \"end\"\n          }\n        ]\n      }\n    ]\n  }\n]\n```\n\n# LICENSE\n[MPL-2.0][LICENSE]\n\n[LICENSE]: https://tldrlegal.com/license/mozilla-public-license-2.0-(mpl-2)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fewasm%2Fwasm-json-toolkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fewasm%2Fwasm-json-toolkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fewasm%2Fwasm-json-toolkit/lists"}