Templates

The DocStudio template format: schemaVersion, config, styles, page header and footer, body nodes, versioning, and how unknown properties are handled.

A template is plain JSON that describes a document. It never contains code, and DocStudio never evaluates JavaScript from a template.

Shape

Property Meaning
schemaVersion Required. Semantic version of the template schema, currently 1.0.0
body Required. An array of nodes
name, description, id Optional metadata
config page, locale, missingData, tokens, theme
styles Named styles that nodes reference with styleRef
page header and footer regions, each with a height and children
imports Reusable components pinned by version

Page settings in config.page: size, orientation, margins, direction (ltr or rtl), mode (flow or fixed) and background. Sizes and margins use millimetres.

Nodes

Every node has a unique id and a type. The types are text, image, divider, shape, stack, row, grid, fixed, section, table, repeater, pageNumber, qr, barcode, component and slot. All nodes can also carry style, styleRef, styleWhen, when, frame, width, height and break.

Validation

Objects are closed: an unknown property is an error, so a typo or a template written for a newer schema is reported instead of being silently misread. Validation returns diagnostics with a JSON Pointer path to the offending value. Use validateTemplateStructure from docstudio/core to check a template without rendering it.

Versioning

The schema has its own version. Every schema change ships with a migration, and the engine migrates older templates when it reads them. In the designer, a migrated template is read-only until the author accepts the result, and it is never saved automatically.

Published component versions are immutable and pinned by name, version and content hash.

Untrusted input

Treat templates as untrusted data. The format is a closed schema with limits on size, node count and nesting, only whitelisted style properties are serialized, and image sources must be asset: identifiers or https URLs.

Last updated 2026-12-03