{"id":21553,"library":"markdown-to-json","title":"markdown-to-json","description":"A Python library for converting Markdown content into structured dictionaries or JSON, commonly used for extracting headings, paragraphs, and metadata. Current version 2.1.2, supports Python >=3.8, maintained by njvack on GitHub.","status":"active","version":"2.1.2","language":"python","source_language":"en","source_url":"https://github.com/njvack/markdown-to-json","tags":["markdown","json","parser","markdown-to-json"],"install":[{"cmd":"pip install markdown-to-json","lang":"bash","label":"Install library"}],"dependencies":[],"imports":[{"note":"The correct import is the module itself; the function is accessed as markdown_to_json.markdown_to_json, but the module is the common top-level import.","wrong":"from markdown_to_json import markdown_to_json","symbol":"markdown_to_json","correct":"import markdown_to_json"}],"quickstart":{"code":"import markdown_to_json\n\nmarkdown_text = \"\"\"# Hello World\n\nThis is a paragraph.\n\"\"\"\n\n# Convert to dict\nresult = markdown_to_json.markdown_to_json(markdown_text)\nprint(result)\n# Output: {'Hello World': 'This is a paragraph.'}","lang":"python","description":"Parse Markdown text into a Python dictionary."},"warnings":[{"fix":"Update code that expects a JSON string to handle a dict, or call json.dumps() on the result.","message":"Version 2.0 changed the output format: It no longer returns a JSON string; markdown_to_json.markdown_to_json returns a Python dict. Use json.dumps() if you need a string.","severity":"breaking","affected_versions":"2.0 and above"},{"fix":"Ensure your Markdown structure uses one paragraph per heading if you need full capture.","message":"The library only preserves the first paragraph under each heading; nested content may be lost or flattened.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use `import markdown_to_json` then call `markdown_to_json.markdown_to_json()`.","cause":"Incorrect import path: Some users try to import the function directly instead of the module.","error":"AttributeError: module 'markdown_to_json' has no attribute 'markdown_to_json'"},{"fix":"Read the Markdown file into a string first: `with open('file.md') as f: text = f.read()`.","cause":"Passing a non-string (e.g., a file object) to markdown_to_json.","error":"TypeError: expected string or bytes-like object"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}