Skip to main content

jmd-format — Python Reference Implementation

Python reference implementation of the JMD specification (v0.3.6). Includes a C-accelerated parser and serializer, plus lossless XML↔JMD and JSONC↔JMD conversion. Requires Python 3.11 or later.

Installation

Install from PyPI:

pip install jmd-format

Pin a release, or add the optional XML support (lxml):

pip install "jmd-format==0.11.0"
pip install "jmd-format[xml]"

PyPI carries pre-built wheels with the C extensions for CPython 3.11–3.14 on Linux (x86_64, glibc 2.17 or later), macOS (Apple silicon), and Windows (32- and 64-bit). Everywhere else pip installs from the source distribution: the C extensions are compiled when a C compiler is available, and the pure-Python fallback is used transparently otherwise.

Quick Start

from jmd import parse, serialize

doc = parse("""
# Order
id: 42
status: pending

## customer
name: Anna Müller
email: anna@example.com
""")

print(doc.mode, doc.label)
# data Order
print(doc.value)
# {'id': 42, 'status': 'pending', 'customer': {'name': 'Anna Müller', 'email': 'anna@example.com'}}

print(serialize(doc))                       # label and frontmatter from the envelope
print(serialize(doc.value, label="Order"))  # or from a plain value

parse() returns an Envelope carrying mode, label, frontmatter, and the parsed body in value.

Document Modes

from jmd import (
    JMDDeleteParser,
    JMDParser,
    JMDQueryParser,
    JMDSchemaParser,
    jmd_mode,
    parse_error,
)

# Detect mode without full parse
mode = jmd_mode(source)   # 'data' | 'query' | 'schema' | 'delete'

# Query by Example (#?)
query = JMDQueryParser().parse("#? Order\nstatus: pending")

# Schema (#!) — canonical structural parser; values remain raw strings
schema = JMDParser().parse("#! Order\nid: integer readonly\nstatus: string")

# Optional legacy type-expression dialect
typed_schema = JMDSchemaParser().parse(
    "#! Order\nid: integer readonly\nstatus: string"
)

# Delete (#-)
delete = JMDDeleteParser().parse("#- Order\nid: 42")

# Error (# Error)
error = parse_error("# Error\nstatus: 404\ncode: not_found\nmessage: Not found")

Streaming

Use jmd_stream() when the complete source is already available:

from jmd import jmd_stream

for event in jmd_stream(source):
    print(event)

For incremental input, consume the events returned by every process_line() call. finish() emits only events still pending at end of input:

from jmd import JMDStreamParser

parser = JMDStreamParser()
for line in source_lines:
    for event in parser.process_line(line):
        print(event)
for event in parser.finish():
    print(event)

Canonical multiline fields emit FIELD_START followed by one FIELD_CONTENT event per blockquote line. The stream_events() and to_lines() async adapters preserve the same incremental behavior.

XML Mapping

Lossless conversion between data XML and JMD (requires lxml):

from jmd.xml import xml_to_jmd, jmd_to_xml

jmd_source = xml_to_jmd(xml_bytes_or_str)  # XML → JMD string
xml_output  = jmd_to_xml(jmd_source)        # JMD → XML bytes

Targets data XML — OOXML (WordprocessingML, DrawingML, SpreadsheetML), SOAP, XBRL, XRechnung, and similar formats. Mixed-content XML (ODF, XHTML) is out of scope.

See the JMD over XML companion specification for the full mapping rules.

JSONC Mapping

Lossless round-trip between JSONC (JSON with comments and trailing commas) and JMD, standard library only:

from jmd.jsonc import from_jmd, parse_jsonc, serialize_jsonc, to_jmd

doc = parse_jsonc(jsonc_source, root_label="Settings")  # JSONC → AST
jmd_source = to_jmd(doc)                                  # AST → JMD
jsonc_output = serialize_jsonc(from_jmd(jmd_source))      # JMD → JSONC

Comments survive at their original positions: the JMD form carries them as #/ line and #* block markers. The mapping follows the JMD over JSONC companion specification, which is still a draft.

Command Line

The package installs a jmd command:

jmd to-json order.jmd                     # JMD → JSON
jmd from-json order.json --label Order    # JSON → JMD
jmd render order.jmd -o order.html        # JMD → HTML
jmd roundtrip order.jmd                   # check JMD → JSON → JMD is lossless
cat order.jmd | jmd to-json               # without a file, input comes from stdin

jmd without arguments, or with --help, prints the usage text and nothing else. python -m jmd is equivalent.

C Extensions

Build manually if needed:

python build_ext.py build_ext --inplace

Specification

See jmd-spec for the full format specification, benchmark results, and design documentation.

License

Licensed under the Apache License, Version 2.0. See LICENSE.

The JMD format specification is licensed separately under CC BY 4.0.

Metadata

Release files for jmd-format 0.11.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jmd-format 0.11.0
File Size Uploaded Provenance Actions
jmd_format-0.11.0.tar.gz 135.9 kB Without provenance Details for jmd_format-0.11.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for jmd-format 0.11.0
File Actions
jmd_format-0.11.0-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details for jmd_format-0.11.0-cp314-cp314-win_amd64.whl
jmd_format-0.11.0-cp314-cp314-win32.whl CPython 3.14 CPython 3.14 Windows x86-32 Details for jmd_format-0.11.0-cp314-cp314-win32.whl
jmd_format-0.11.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details for jmd_format-0.11.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
jmd_format-0.11.0-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details for jmd_format-0.11.0-cp314-cp314-macosx_11_0_arm64.whl
jmd_format-0.11.0-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details for jmd_format-0.11.0-cp313-cp313-win_amd64.whl
jmd_format-0.11.0-cp313-cp313-win32.whl CPython 3.13 CPython 3.13 Windows x86-32 Details for jmd_format-0.11.0-cp313-cp313-win32.whl
jmd_format-0.11.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details for jmd_format-0.11.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
jmd_format-0.11.0-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details for jmd_format-0.11.0-cp313-cp313-macosx_11_0_arm64.whl
jmd_format-0.11.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details for jmd_format-0.11.0-cp312-cp312-win_amd64.whl
jmd_format-0.11.0-cp312-cp312-win32.whl CPython 3.12 CPython 3.12 Windows x86-32 Details for jmd_format-0.11.0-cp312-cp312-win32.whl
jmd_format-0.11.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details for jmd_format-0.11.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
jmd_format-0.11.0-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details for jmd_format-0.11.0-cp312-cp312-macosx_11_0_arm64.whl
jmd_format-0.11.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details for jmd_format-0.11.0-cp311-cp311-win_amd64.whl
jmd_format-0.11.0-cp311-cp311-win32.whl CPython 3.11 CPython 3.11 Windows x86-32 Details for jmd_format-0.11.0-cp311-cp311-win32.whl
jmd_format-0.11.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details for jmd_format-0.11.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
jmd_format-0.11.0-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details for jmd_format-0.11.0-cp311-cp311-macosx_11_0_arm64.whl

Total release size: 2.6 MB

Release files / jmd_format-0.11.0.tar.gz

Download URL jmd_format-0.11.0.tar.gz
Size 135.9 kB
Tags Source
SHA-256 checksum
How to use checksums
4ec8fcfde9ea8051aff798e65fcda3203431ab9382d55c389c749d57626d955f
BLAKE2b-256 checksum
How to use checksums
c04f176ce974787760db9fa00cec04479115487e98a5390d83a796b40bf52a55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / jmd_format-0.11.0-cp314-cp314-win_amd64.whl

Download URL jmd_format-0.11.0-cp314-cp314-win_amd64.whl
Size 137.6 kB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
1d172829c12a5f3f115b5a9c6f6e807b6176d32d14119d5c8b46aca9230bc83a
BLAKE2b-256 checksum
How to use checksums
0cf7507eab7b59b38f8b08db745cd752f8e3214834954c249aa82b5e962ebb91
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / jmd_format-0.11.0-cp314-cp314-win32.whl

Download URL jmd_format-0.11.0-cp314-cp314-win32.whl
Size 134.5 kB
Tags CPython 3.14 Windows x86-32
SHA-256 checksum
How to use checksums
441029d88b488369f292f887f4bbc01b50d736f15d4bcc5053d6d1f23f84cb1c
BLAKE2b-256 checksum
How to use checksums
874068792c99ae8b7a2f96b95b14be24768be6ef9f730123232d3e0fee45e92b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / jmd_format-0.11.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL jmd_format-0.11.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 218.3 kB
Tags CPython 3.14 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
a5bc8a843b934e67755e5eae2e00c37d6612622b08e77e92459c8a53090f4770
BLAKE2b-256 checksum
How to use checksums
965db2d51d1914fbb095c7e734cbaa03c73f6ec08b727ca6ceab22e6b8adcb8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / jmd_format-0.11.0-cp314-cp314-macosx_11_0_arm64.whl

Download URL jmd_format-0.11.0-cp314-cp314-macosx_11_0_arm64.whl
Size 134.1 kB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
82b1f285fe628b4866b5a574690a7339da95e9542f952b665ac824879403fbe9
BLAKE2b-256 checksum
How to use checksums
5710e282ba385636068a1bf05477ce4623aded3e42b6216d54cd7f410b7bf15b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / jmd_format-0.11.0-cp313-cp313-win_amd64.whl

Download URL jmd_format-0.11.0-cp313-cp313-win_amd64.whl
Size 137.1 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
7c1d0b0f2c978ca69e26a00d5547351a3369faab45dbcf9f85ad91d4ca10c8a8
BLAKE2b-256 checksum
How to use checksums
c3850eb67cc387cc3757e881e9dc147450d37433a2a1fe1a056b8c4a69d6bc5b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / jmd_format-0.11.0-cp313-cp313-win32.whl

Download URL jmd_format-0.11.0-cp313-cp313-win32.whl
Size 134.1 kB
Tags CPython 3.13 Windows x86-32
SHA-256 checksum
How to use checksums
4963ed76d88cc976b944fc048bead9604a2418e90bf79c85d0ca6a7eef642403
BLAKE2b-256 checksum
How to use checksums
9d2d11fd38ca484e5e3bf81865600ab4813cf76d8cf53bfa62f6ef26f439ca34
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / jmd_format-0.11.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL jmd_format-0.11.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 217.9 kB
Tags CPython 3.13 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
7dee009232c96391ec1327a487afbf75baf1b44689d39c7ad32030f915133710
BLAKE2b-256 checksum
How to use checksums
8867a6ff56b0e09ff43737cfd2dfb822eb39594ecc3b437d22b4ef22e031b1f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / jmd_format-0.11.0-cp313-cp313-macosx_11_0_arm64.whl

Download URL jmd_format-0.11.0-cp313-cp313-macosx_11_0_arm64.whl
Size 134.1 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a12aa3cc74f415b33cafa2b20963c4bb3b448cd319f6f42aea99bebc094270cb
BLAKE2b-256 checksum
How to use checksums
f3feabcf700095a1bbb0ba97afe679b06995c8b372fcad428e4cc0cdd93aa827
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / jmd_format-0.11.0-cp312-cp312-win_amd64.whl

Download URL jmd_format-0.11.0-cp312-cp312-win_amd64.whl
Size 137.1 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
278eb680f93e1eec1e3eee374c6f6078bf5fd09b3947efc11a09f17af22d556b
BLAKE2b-256 checksum
How to use checksums
78fcd942882b420639a76ca21a3fa1bcb1ec0985f98192345dced80f1455d65b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / jmd_format-0.11.0-cp312-cp312-win32.whl

Download URL jmd_format-0.11.0-cp312-cp312-win32.whl
Size 134.1 kB
Tags CPython 3.12 Windows x86-32
SHA-256 checksum
How to use checksums
5a30e6b435c38536c61ac3d16309e166f9b644d11f7ea30c5f607435f54fb279
BLAKE2b-256 checksum
How to use checksums
3d70dd12e7b398c582a5eb29459adef3d813fcd064c8e0b4c3e91e68b74636e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / jmd_format-0.11.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL jmd_format-0.11.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 217.5 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
f09505ca331654afd73e3089f78fa8b1595cac0531fa20cf821e239b897a24ca
BLAKE2b-256 checksum
How to use checksums
7262e7617690de857bc23770bd5c50c50bed26b2ee840cd69e6380a65c3cdae8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / jmd_format-0.11.0-cp312-cp312-macosx_11_0_arm64.whl

Download URL jmd_format-0.11.0-cp312-cp312-macosx_11_0_arm64.whl
Size 134.1 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
b0912eae77c58888a54e7e2dc78b7f7c45a048af9acdf436f2024525ac7b59d8
BLAKE2b-256 checksum
How to use checksums
e24df3bc924aaac15edb8254af058ad9a1616d11e86af8ec364c964ffb96956f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / jmd_format-0.11.0-cp311-cp311-win_amd64.whl

Download URL jmd_format-0.11.0-cp311-cp311-win_amd64.whl
Size 137.0 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
2907492737e6face1f04f7fc4ed733da506bf4eb7c9d553146f10badd66f37c4
BLAKE2b-256 checksum
How to use checksums
71e8b2af6dca8ab1dc92142a8c1a3cf651a49b2ac2aa8e8bb63762b6da41830d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / jmd_format-0.11.0-cp311-cp311-win32.whl

Download URL jmd_format-0.11.0-cp311-cp311-win32.whl
Size 133.9 kB
Tags CPython 3.11 Windows x86-32
SHA-256 checksum
How to use checksums
405e8223790502928a2b143b5eecd123f76b543fac78fc4a18e8caabb2b71e8c
BLAKE2b-256 checksum
How to use checksums
e49dab3129d3b29d4cd9557cd4e1d8c52388ba15e344c52a51c814aa30236e0d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / jmd_format-0.11.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL jmd_format-0.11.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 212.3 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
f5bdb19c1e0812a6088bdf6e19a6bf0ef704f5eb63ead91ba63b81d3fcd4753d
BLAKE2b-256 checksum
How to use checksums
dca1684c23083ee8743fd55544c12bae79e14befc444c8c4d36a311cc0f93ab2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / jmd_format-0.11.0-cp311-cp311-macosx_11_0_arm64.whl

Download URL jmd_format-0.11.0-cp311-cp311-macosx_11_0_arm64.whl
Size 133.8 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
98188b7306609a6af95ae1fa453d05259f503079539db2864d7d71c6dd0dfccf
BLAKE2b-256 checksum
How to use checksums
0f6beea85b7e7123a507d9b52c731437c2f336584281cecfc05e43f7145cf98b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for jmd-format 0.11.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page