Registry / serialization / markdown-to-json

markdown-to-json

JSON →
library2.1.2pypypi✓ verified 85d ago

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.

pip install markdown-to-json
INSTALL
IMPORT
SIG · MARKDOWN-TO-JSON
M
markdown-to-json
serializationpythonv2.1.2
Install
1.6s avg
Import
92ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.1.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.094s · 18.3MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.090s · 19MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

markdown_to_json
import markdown_to_json
from markdown_to_json import markdown_to_json
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.

Parse Markdown text into a Python dictionary.

import markdown_to_json markdown_text = """# Hello World This is a paragraph. """ # Convert to dict result = markdown_to_json.markdown_to_json(markdown_text) print(result) # Output: {'Hello World': 'This is a paragraph.'}
Debug
Known issues
breakingVersion 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.
fix
Update code that expects a JSON string to handle a dict, or call json.dumps() on the result.
affects: 2.0 and above
gotchaThe library only preserves the first paragraph under each heading; nested content may be lost or flattened.
fix
Ensure your Markdown structure uses one paragraph per heading if you need full capture.
affects: all
Errors
Common errors & fixes
AttributeError: module 'markdown_to_json' has no attribute 'markdown_to_json'
Incorrect import path: Some users try to import the function directly instead of the module.
fix
Use `import markdown_to_json` then call `markdown_to_json.markdown_to_json()`.
TypeError: expected string or bytes-like object
Passing a non-string (e.g., a file object) to markdown_to_json.
fix
Read the Markdown file into a string first: `with open('file.md') as f: text = f.read()`.
Upgrade
Version history
2.1.2latest on PyPI · released Sep 20, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
markdown-to-json — pip install markdown-to-json · libregistry