{"id":17304687,"url":"https://github.com/moinism/jsonfromhtml","last_synced_at":"2025-04-14T13:20:31.264Z","repository":{"id":57285723,"uuid":"258831305","full_name":"moinism/jsonfromhtml","owner":"moinism","description":"NPM package to convert HTML to JSON","archived":false,"fork":false,"pushed_at":"2020-04-26T16:04:08.000Z","size":7,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-25T11:43:30.604Z","etag":null,"topics":["html","html2json","javascript","json","node","npm"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/moinism.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-25T17:14:21.000Z","updated_at":"2024-01-13T22:48:27.000Z","dependencies_parsed_at":"2022-08-24T18:14:15.079Z","dependency_job_id":null,"html_url":"https://github.com/moinism/jsonfromhtml","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moinism%2Fjsonfromhtml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moinism%2Fjsonfromhtml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moinism%2Fjsonfromhtml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moinism%2Fjsonfromhtml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moinism","download_url":"https://codeload.github.com/moinism/jsonfromhtml/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248886334,"owners_count":21177645,"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":["html","html2json","javascript","json","node","npm"],"created_at":"2024-10-15T11:53:39.168Z","updated_at":"2025-04-14T13:20:31.232Z","avatar_url":"https://github.com/moinism.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Turn HTML DOM to JSON-able structure\n\n👌 Zero dependencies ⚡️ Ultra lightweight\n\n```\nnpm i -S jsonfromhtml\n```\n\n```js\nconst { jsonFromHTML } = require('jsonfromhtml')\n\nconst body = jsonFromHTML(document.body) // returns object\nconst json = JSON.stringify(body)\n```\n\n## Usage\n\n```js\nconst element = jsonFromHTML(domElement)\n```\n\nParameter:\n - `domElement`: Expects a DOM element. Use a package like [cheerio](https://www.npmjs.com/package/cheerio) to use it in node envoirnment.\n\n\nReturns:\n- An `Object`.\n\n### Returned `Object` Example\n\nInput:\n\n```html\n\u003cp\u003e\nHere is my \u003ca href=\"https://github.com/moinism\" target=\"_blank\"\u003eGithub\u003c/a\u003e if you wanna have a looksy.\n\u003c/p\u003e\n```\n\nOutput:\n\n```js\n{\n  \"nodeName\": \"P\", // tag name\n  \"nodeType\": \"element\", // either 'element' or 'text'\n  \"attrs\": {}, // only for nodeType == 'element'\n  \"children\": [\n    {\n      \"content\": \"\\nHere is my \",\n      \"nodeType\": \"text\"\n    },\n    {\n      \"nodeName\": \"A\",\n      \"nodeType\": \"element\",\n      \"attrs\": { // key-value pairs of all the attributes on the element.\n        \"href\": \"https://github.com/moinism\",\n        \"target\": \"_blank\"\n      },\n      \"children\": [\n        {\n          \"content\": \"Github\",\n          \"nodeType\": \"text\"\n        }\n      ]\n    },\n    {\n      \"content\": \" if you wanna have a looksy.\\n\",\n      \"nodeType\": \"text\"\n    }\n  ]\n}\n```\n\n\n### LICENSE\n\nMIT","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoinism%2Fjsonfromhtml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoinism%2Fjsonfromhtml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoinism%2Fjsonfromhtml/lists"}