Skip to content

document-render

One JSON document. Word, PDF and HTML out.

The JSON says what goes on the page: headings, paragraphs, lists, tables, images, plus a little styling. document-render does the layout.

hello.json
{
"version": "0.1",
"meta": { "title": "Quarterly report", "lang": "en", "page": { "size": "A4", "margin": "20mm" } },
"styles": { "muted": { "color": "#666666", "fontSize": 10 } },
"root": "doc",
"elements": {
"doc": { "type": "Document", "children": ["title", "intro", "items"] },
"title": { "type": "Heading", "props": { "level": 1, "text": "Quarterly report" } },
"intro": { "type": "Text", "props": { "text": "One JSON file, three formats." }, "style": "muted" },
"items": { "type": "List", "props": { "items": ["docx", "pdf", "html"] } }
}
}
终端窗口
document-render render hello.json -o hello.docx
document-render render hello.json -o hello.pdf
document-render render hello.json -o hello.html --paged

One source, three formats

The same JSON renders to docx, pdf and html. If a format can’t express a style, you get a warning, not an error.

CSS-like styles

Field names follow CSS: fontSize, lineHeight, border. Values follow what Word can express.

Style sets

Put a house style in a style set and share it across documents. Switch the set, switch the look.

Tables and sections

Merged cells, column widths, row heights, repeated headers; sections with their own paper, headers, footers and page numbers.

Custom components

Combine built-ins into your own components and use them in one line.

Easy for AI to write

Elements are flat and reference each other by id. An AI can emit them one by one, and document-render check tells it exactly what’s wrong.