Introduction to DocStudio
What DocStudio is, the problem it solves, how a template, data and renderer fit together, and where to go next.
DocStudio is a TypeScript toolkit for generating documents from data. You describe a document once as a JSON template, merge JSON data into it, and render the result as HTML, print output or PDF.
The idea
A template and a data object go in. A framework-independent core validates the template, binds the data and compiles everything into a resolved document tree. A renderer turns that tree into HTML and CSS. The same renderer produces the designer preview and the final output, so what you see while designing is what you print.
- Migrate and validate the template against the schema.
- Bind data paths and evaluate expressions.
- Compile to the resolved document tree, plain JSON with no bindings left.
- Render the tree to HTML and CSS.
- Output through the browser print dialog or a server-side PDF service.
What is in the package
DocStudio is one npm package, docstudio, with subpath exports:
| Import | Use it for |
|---|---|
docstudio |
compile, render and the one-call renderDocument |
docstudio/core |
Schema, validation, binding, expressions, compilation |
docstudio/render |
Resolved tree to HTML and CSS |
docstudio/designer |
The React visual editor |
docstudio/pdf |
Browser-safe PDF client and printHtml |
docstudio/server |
Node PDF service built on Playwright and Chromium |
You can use the core and renderer on their own, with no React and no browser, and add the designer only where people edit templates.
What it is not
DocStudio does not ship its own layout or pagination engine. HTML and CSS are the canonical output, and PDF is produced by Chromium. It is also not tied to one kind of document: invoices, reports, certificates and forms are all templates.