{"id":46905606,"url":"https://github.com/connected-web/md2json","last_synced_at":"2026-03-11T01:10:07.085Z","repository":{"id":42584290,"uuid":"416828751","full_name":"connected-web/md2json","owner":"connected-web","description":"A functional library that takes a markdown body; and tries to create a JSON representation of the document.","archived":false,"fork":false,"pushed_at":"2023-07-19T04:56:59.000Z","size":206,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-09T17:14:08.588Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/connected-web.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}},"created_at":"2021-10-13T16:59:52.000Z","updated_at":"2022-01-05T16:01:48.000Z","dependencies_parsed_at":"2023-02-08T04:15:14.854Z","dependency_job_id":null,"html_url":"https://github.com/connected-web/md2json","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/connected-web/md2json","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/connected-web%2Fmd2json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/connected-web%2Fmd2json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/connected-web%2Fmd2json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/connected-web%2Fmd2json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/connected-web","download_url":"https://codeload.github.com/connected-web/md2json/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/connected-web%2Fmd2json/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30365047,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T21:41:54.280Z","status":"ssl_error","status_checked_at":"2026-03-10T21:40:59.357Z","response_time":106,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2026-03-11T01:10:06.223Z","updated_at":"2026-03-11T01:10:06.996Z","avatar_url":"https://github.com/connected-web.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Markdown 2 Json\n\nA functional library that takes a markdown body; and tries to create a JSON representation of the document.\n\n## Supports\n\n- Headings\n- Lists\n- Paragraphs\n\n## Usage\n\nInstall:\n- `npm install @connected-web/md2json`\n\n```js\nconst md2json = require('@connected-web/md2json')\nconst fs = require('fs')\n\nconst filename = 'README.md'\nconst md = fs.readFileSync(filename, 'utf8')\nconst json = md2json(filename, md)\n\nconsole.log('Markdown to Json:', json)\n```\n\n## Examples\n\n- Default example output: [`examples/example-output.json`](./examples/example-output.json)\n- Default tokens output: [`examples/example-output-tokens.json`](./examples/example-output-tokens.json)\n- json2md tokens output: [`examples/example-output-json2md.json`](./examples/example-output-json2md.json)\n- Test output: [`examples/test-output.json`](./examples/test-output.json)\n\n## Source only API\n\n```js\nmd2json(markdown)\n```\n\n## Title and source API\n\n```js\nmd2json(title, markdown)\n```\n\n## Options object API\n```js\nmd2json({\n  title: 'README.md',\n  markdown: '# Heading\\n\\nContent'\n})\n```\n\n### Option : `title`\n\nThe top level section of the JSON output.\n\n### Option : `markdown` | `md`\n\nThe text string representing the markdown to be converted to JSON\n\n### Option : `outputFormat`\n\nThe type of formatting to output.\n\n- `{ outputFormat: 'default' }` : Empty string will default to default - a nested structure of markdown as JSON\n- `{ outputFormat: 'json2md' }` : Token format compatable with [IonicaBizau/json2md ](https://github.com/IonicaBizau/json2md) (npm: [json2md](https://www.npmjs.com/package/json2md))\n\n## Tokens\n\n```js\nconst md2json = require('@connected-web/md2json')\nconst tokens = md2json.tokens('# Heading\\n\\nContent\\n\\n## Heading 1.1')\nconsole.log(tokens)\n```\n\nOutput:\n```json\n[\n  {\n    \"name\": \"h1\",\n    \"text\": \"Heading\"\n  },\n  {\n    \"name\": \"p\",\n    \"text\": \"Content\"\n  },\n  {\n    \"name\": \"h2\",\n    \"text\": \"Heading 1.1\"\n  }\n]\n```\n\n## Tokens for json2md \n\nInstead of using the `outputFormat: json2md` option - which is compatable with [IonicaBizau/json2md ](https://github.com/IonicaBizau/json2md) (npm: [json2md](https://www.npmjs.com/package/json2md)), you can directly call this method:\n\n```js\nconst md2json = require('@connected-web/md2json')\nconst tokens = md2json.json2mdTokens('# Heading\\n\\nContent\\n\\n## Heading 1.1')\nconsole.log(tokens)\n```\n\nOutput:\n```json\n[\n  {\n    \"h1\": \"Heading\"\n  },\n  {\n    \"p\": \"Content\"\n  },\n  {\n    \"h2\": \"Heading 1.1\"\n  }\n]\n```\n\nYou can then feed these tokens back into `json2md` to create markdown again.\n\nNot all formats and formatting are supported; this isn't guarenteed as a fully backwards compatable transformation - but please [raise an issue](https://github.com/connected-web/md2json/issues/new) with an example.\n\n## Approach\n\n- Format parameters\n- Render Markdown as HTML\n- Create DOM from Markdown\n- Create Tokens in the form: `{ name: el.tagName, text: el.text }`\n- Parse Tokens into Hierarchy\n- Return JSON hierarchy\n\n## Known Issues\n\n- Inline formats not fully supported, e.g.:\n  - **bold** and *italic* text will be reduced to plain text\n  - the markdown equivalent of a `\u003ccode\u003ecode block\u003c/code\u003e` will duplicate the code text into a new block\n\n## Licenses\n\nReleased under ISC.\n\n### Dependencies\n\n- marked\n- cheerio\n\n### Development tools\n\n- mocha\n- chai\n- standard\n\n## Changelog\n\n### 1.3.0\n\n- Add options to support json2md compatible output\n- Support a broader range of HTML tokens, including blockquote, img, code, table, tr, th, td\n\n### 1.2.0\n\n- Fix failing tests based on `marked` interface\n- Add PR checking to project\n\n### 1.1.0\n\n- Add `.tokens(markdown)` method to API\n\n### 1.0.0\n\n- First version ready for release\n- Not perfect, but hopefully something people can work with\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconnected-web%2Fmd2json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fconnected-web%2Fmd2json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconnected-web%2Fmd2json/lists"}