Streaming document conversion that keeps as little of the document in memory as the format allows.
Documents, as they flow. DocSpec reads a document as a stream of typed events and writes it back out in another format — one event at a time, in constant memory for DOCX and HTML read from a path apart from the cases under Not bounded; Markdown is bounded by its input size. Streaming is the whole point; the Manifesto explains why.
Funded by NLnet through the NGI0 Commons Fund, and the Netherlands' Ministry of the Interior and Kingdom Relations.
Used by DINUM — La Suite Numérique.
Two ways in, depending on what you need.
Install with Cargo:
cargo install docspec-cli
Convert a document — the formats are inferred from the input and output file extensions:
docspec convert report.docx --output report.md
Or pipe through stdin and name the formats explicitly:
echo '# Hello' | docspec convert --from markdown --to blocknote
The ghcr.io/docspec/api image is the conversion server, ready to run with no Rust toolchain:
docker run --rm -p 3000:3000 ghcr.io/docspec/api
Installed the CLI instead? It ships the same server:
docspec http # serves on 127.0.0.1:3000Either way, send it a document — the Content-Type picks the reader, the Accept header picks the writer (BlockNote JSON by default):
curl -X POST http://localhost:3000/conversion \
-H 'Content-Type: text/markdown' \
-d '# Hello'GET /conversion lists the media types the running server reads and writes, GET /openapi.json describes the conversion and health endpoints in OpenAPI 3.1, GET /health is the liveness check; docspec-http has the full endpoint, header, and format reference.
Readers and writers are fully decoupled: any reader can feed any writer, because the event stream is the only contract between them. That decoupling is mechanical — every pairing runs, but a conversion is only as faithful as its least-capable endpoint.
Formats carry one of two statuses:
- Supported — intended for production use within its documented mapping. Common document structure is covered, and the known limitations are part of the maintained contract. This does not mean lossless interchange.
- Experimental — coverage is deliberately incomplete. Common structures may be silently omitted from the output. Don't rely on it where fidelity matters.
| Direction | Format | Status | Coverage today |
|---|---|---|---|
| Reads | DOCX | Supported | Headings, tables, lists, hyperlinks, images, run styles, colors |
| Reads | Markdown | Supported | CommonMark + GFM tables and strikethrough1 |
| Reads | HTML | Experimental | <p> elements and their text only — every other tag is dropped |
| Writes | BlockNote JSON | Supported | Headings, lists, tables, links, images, styles, quotes, code |
| Writes | Pandoc native | Experimental | Paragraphs, headings, styles, code; no lists, tables, links, images |
| Writes | Markdown | Experimental | Paragraphs and headings, text only |
| Writes | HTML | Experimental | Paragraphs and text only |
| Writes | oxa.dev JSON | Experimental | Paragraphs and text only |
This table is the canonical statement of format maturity. Each crate's README remains the authoritative reference for exactly which events it handles and drops.
Most document converters load the whole file into memory, build a tree, and hope it fits. That works until someone uploads a 200 MB report — or until you need the same converter to run inside a browser tab. DocSpec exists to turn real-world documents into what modern web editors actually consume — BlockNote JSON, oxa.dev — event by event, holding as little of the document as each parser allows.
Streaming event by event is the one decision everything else follows from:
- It runs where your editor runs. The same Rust compiles to a native server, a WebAssembly module in the browser, or an embedded target — one codebase, every surface, no separate front-end and back-end converters drifting apart.
- Its memory stays flat. For DOCX and HTML read from a path, a 1 KB note and a 500 MB document cost about the same to convert, apart from the cases under Not bounded. Markdown is bounded by its input size.
- It stays honest. On corrupt input it stops and says so — no half-converted output quietly reaching your database.
DocSpec is the Rust successor to NLdoc, rebuilt for public-sector digital sovereignty: funded by NLnet and the Dutch Ministry of the Interior, and used in production by La Suite to import documents into its collaborative editor. The Manifesto is the long version of why.
DocSpec is a Cargo workspace. Most users want the docspec facade;
reach for the individual crates when you want the smallest possible dependency footprint.
Core
docspec— convenience facade; readers, writers, and core types behind feature flagsdocspec-core— the event model, theEventSource/EventSinktraits, and the streaming pipeline
Readers
docspec-docx-reader— DOCXdocspec-html-reader— HTMLdocspec-markdown-reader— Markdown (CommonMark + GFM)docspec-odt-reader— ODT (placeholder: emits an empty document)
Writers
docspec-html-writer— HTMLdocspec-markdown-writer— Markdowndocspec-blocknote-writer— BlockNote JSONdocspec-oxa-writer— oxa.dev JSONdocspec-pandoc-native-writer— Pandoc native
Primitives & tooling
docspec-json— streaming JSON emission primitives for custom writersdocspec-cli— thedocspeccommand-line binarydocspec-http— the HTTP conversion serverdocspec-wasm— WebAssembly bindings
- Manifesto — philosophy and values
- Architecture — the streaming pipeline, reader/writer contracts, and the event model
- Coding Standards — the code style and the review bar
- Contributing — workflow, commits, PRs, semver
- Bug Triage & Reporting — filing actionable bug reports and how we triage them
- Testing — the coverage floor and test philosophy
- Security — error handling by context, resource limits
- Agents — guidance for AI agents working in this repo
- Memory conscious — constant memory for DOCX and HTML read from a path apart from the cases under Not bounded, Markdown bounded by input size; every allocation earns its keep.
- Streaming first — events flow one at a time; for DOCX and HTML read from a path, nothing accumulates apart from the cases under Not bounded.
- Fail fast — on corruption we stop and say so: no partial output, no silent truncation.
- No unsafe — the workspace forbids
unsafeentirely. - Proven — a 98% coverage floor on new and changed executable Rust lines in covered crates; no
unwraporexpectin source.
DocSpec is under active development. The architecture is stable and the event model is defined; readers and writers land incrementally. We keep the public API honest about what is supported today versus what a crate silently drops.
DocSpec is built in the open, and contributions are welcome — a new reader or writer, a bug fix, a sharper doc, a failing test that pins down an edge case. We hold a high bar (no unsafe, no unwrap in source, a 98% coverage floor on new and changed executable Rust lines in covered crates), but the bar is written down, not hidden. Start with CONTRIBUTING.md for the full workflow.
A few good entry points:
- Found a bug? Bug Triage & Reporting shows what makes a report we can fix today. Security issues go privately — never a public issue.
- Have an idea, or a design to talk through? Open an issue and tag it as a proposal.
- Ready to write code? Building and Running Locally gets you set up in a few commands.
Every contribution is attributed in the git history, and we treat review as collaboration, not gatekeeping.
MIT.
This work grew out of the mentoring and support of @virgile-dev.
Footnotes
-
The Markdown reader holds the whole source in memory while it parses (
pulldown-cmarkis borrow-based), so peak memory is about 3× the input size. Events still flow one at a time. DOCX and HTML read from a path stream in constant memory apart from the cases under Not bounded. ↩