v0.2.0 / MIT / TypeScript
Professional documents. Built dynamically.
Design document templates visually, bind JSON data, and generate consistent documents from your application.

Documents are usually code
Invoices, reports and certificates tend to start as layout code: coordinates, string templates and one-off styling. Every change needs a developer, and the preview rarely matches the output.
DocStudio keeps them data
A template is JSON. A designer edits it visually, your data is merged into it, and one renderer produces the preview and the output. Designers change the layout, developers supply the data, and nobody edits the other's code.
How it works
Three steps, each usable on its own.
- 01
Design
Build the template in the visual designer, or write the JSON by hand. Templates are versioned data you can store anywhere.
- 02
Bind
Point text, tables and repeaters at paths in your JSON. Add expressions for totals, flags and formats.
- 03
Render
Compile to a resolved tree and render HTML. Print from the browser, or produce a PDF on a server.
What you get
Every item here exists in version 0.2.0. Limits are listed in the documentation.
Visual designer
A React editor with a paper-sized canvas, a toolbox of 14 components, an inspector, layers and undo.
Learn more about visual designerData binding
Bind any JSON to text, tables and repeaters. Expressions are a declarative AST with 35 built-in functions. Nothing is evaluated as JavaScript.
Learn more about data bindingPrint and PDF
Print in the browser with printHtml, or render PDF on a server with Chromium through Playwright.
Learn more about print and pdfTables
Data tables with repeating headers, zebra rows, footers with totals and fixed rows, split across pages.
Learn more about tablesRight to left
English, Arabic and Urdu, with direction, alignment and table order mirrored.
Learn more about right to leftReusable components
Publish a component once and pin it by version in the templates that use it.
Learn more about reusable componentsA template and one call
The template is plain JSON. renderDocument compiles it with your data and returns HTML, or diagnostics when something is wrong. It never throws for template or data problems.
{
"schemaVersion": "1.0.0",
"body": [
{ "id": "title", "type": "text", "content": ["Invoice ", { "path": "number" }] },
{
"id": "lines",
"type": "table",
"source": { "path": "items" },
"columns": [
{ "id": "name", "header": "Item", "cell": { "path": "name" } },
{
"id": "total",
"header": "Total",
"align": "end",
"cell": { "fn": "mul", "args": [{ "path": "qty" }, { "path": "price" }] }
}
]
}
]
}import { renderDocument } from 'docstudio';
const data = {
number: 'INV-1042',
items: [
{ name: 'Design review', qty: 2, price: 120 },
{ name: 'Template setup', qty: 1, price: 480 },
],
};
const result = renderDocument(template, data, { target: 'print' });
if (!result.ok) {
throw new Error(result.diagnostics.map((item) => item.message).join('; '));
}
const html = result.html;Real output from real templates
These images are rendered by the published package from the templates and data on each example page.
Architecture
Templates are migrated, validated, bound and compiled into a resolved document tree. The renderer turns that tree into HTML and CSS, and an output adapter prints it or produces a PDF. The designer preview and the output share the renderer.
| Import | Responsibility |
|---|---|
docstudio | Core, render and renderDocument in one lightweight entry |
docstudio/core | Template schema, validation, migration, binding, expressions, compilation |
docstudio/render | Resolved document tree to HTML and CSS |
docstudio/designer | The React visual editor |
docstudio/pdf | Browser-safe PDF client and printHtml |
docstudio/server | Node PDF service on Playwright and Chromium |
One npm package with one runtime dependency. See requirements.
Start in a few minutes
Install the package, render your first template, then add the designer when you need it.
npm install docstudio

