Skip to content
json-render-office
Esc
↑↓navigate↵open⌘Jpreview
On this page

Documents

The standard components of json-render-docx.

Word components. A Document is the root and holds Section elements. See the overview for how to read the tables.

Document

The Word document. Must be the root element. Children must be Section components. Takes child elements.

Document rendered in LibreOffice
Document in LibreOffice 26.8.3.1.
Prop Type Nullable Description
title string yes File title shown in document properties.
author string yes
language string yes BCP 47 tag such as “en-US”, so Word checks spelling in it.
{
  "type": "Document",
  "props": {
    "title": "Project report",
    "author": "Jane Doe",
    "language": "en-US"
  },
  "children": []
}

Section

A run of pages with one page setup. Most documents have one Section. Children are the page header and footer, then the content. Takes child elements.

Section rendered in LibreOffice
Section in LibreOffice 26.8.3.1.
Prop Type Nullable Description
size enum yes Page size. Default A4. One of A4, Letter, A3, A5, Legal.
orientation enum yes One of portrait, landscape.
margin number yes Page margin in inches. Default 1. 0.25 to 3.
{
  "type": "Section",
  "props": {
    "size": "A4",
    "orientation": "portrait",
    "margin": 1
  },
  "children": []
}

Text repeated at the top of every page of the Section. Put it first in the Section. Has no children: use "children": [].

Header rendered in LibreOffice
Header in LibreOffice 26.8.3.1.
Prop Type Nullable Description
text string no At most 120 characters.
align enum yes Default right. One of left, center, right, justify.
{
  "type": "Header",
  "props": {
    "text": "Project report",
    "align": "right"
  },
  "children": []
}

Text and page numbers repeated at the bottom of every page of the Section. Has no children: use "children": [].

Footer rendered in LibreOffice
Footer in LibreOffice 26.8.3.1.
Prop Type Nullable Description
text string yes At most 120 characters.
pageNumbers boolean yes Add “Page X of Y” after the text.
align enum yes Default center. One of left, center, right, justify.
{
  "type": "Footer",
  "props": {
    "text": "Confidential",
    "pageNumbers": true,
    "align": null
  },
  "children": []
}

Title

The document title, once, at the top of the first page. Has no children: use "children": [].

Title rendered in LibreOffice
Title in LibreOffice 26.8.3.1.
Prop Type Nullable Description
text string no At most 120 characters.
align enum yes One of left, center, right, justify.
{
  "type": "Title",
  "props": {
    "text": "Quarterly report",
    "align": null
  },
  "children": []
}

Heading

A heading. Word lists headings in its navigation pane and in a TableOfContents. Has no children: use "children": [].

Heading rendered in LibreOffice
Heading in LibreOffice 26.8.3.1.
Prop Type Nullable Description
text string no At most 120 characters.
level integer no 1 is a chapter, 3 the smallest. 1 to 3.
{
  "type": "Heading",
  "props": {
    "text": "Results",
    "level": 1
  },
  "children": []
}

Paragraph

A paragraph of body text. Has no children: use "children": [].

Paragraph rendered in LibreOffice
Paragraph in LibreOffice 26.8.3.1.
Prop Type Nullable Description
text string no A line feed in the text starts a new line. At most 3000 characters.
align enum yes One of left, center, right, justify.
bold boolean yes
italic boolean yes
color string yes
fontSize number yes Points. Null uses the theme size. 8 to 28.
{
  "type": "Paragraph",
  "props": {
    "text": "Revenue grew in every quarter.",
    "align": null,
    "bold": null,
    "italic": null,
    "color": null,
    "fontSize": null
  },
  "children": []
}

List

A bulleted or numbered list. Has no children: use "children": [].

List rendered in LibreOffice
List in LibreOffice 26.8.3.1.
Prop Type Nullable Description
items string[] no 1 to 30 items, each at most 300 characters.
ordered boolean yes Numbered instead of bulleted.
{
  "type": "List",
  "props": {
    "items": [
      "Faster checkout",
      "Better search"
    ],
    "ordered": false
  },
  "children": []
}

Table

A native table with a header row that repeats on every page the table spans. Has no children: use "children": [].

Table rendered in LibreOffice
Table in LibreOffice 26.8.3.1.
Prop Type Nullable Description
columns string[] no Header labels, one per column. 1 to 6 items, each at most 40 characters.
rows string[][] no One string per column in each row. 1 to 60 items, each at most 6 items, each at most 200 characters.
striped boolean yes Shade every second row.
{
  "type": "Table",
  "props": {
    "columns": [
      "Team",
      "Owner"
    ],
    "rows": [
      [
        "Checkout",
        "Mira"
      ],
      [
        "Search",
        "Tomas"
      ]
    ],
    "striped": null
  },
  "children": []
}

Image

A centered picture. Always give alt text. Has no children: use "children": [].

Image rendered in LibreOffice
Image in LibreOffice 26.8.3.1.
Prop Type Nullable Description
src string no An https URL or a data: URI. Local paths are not allowed.
alt string no What the image shows, for screen readers. At most 200 characters.
width number yes Inches. Default 5. 0.5 to 6.5.
{
  "type": "Image",
  "props": {
    "src": "https://picsum.photos/800/450?random=1",
    "alt": "A mountain lake",
    "width": 5
  },
  "children": []
}

PageBreak

Starts the next element on a new page. Has no children: use "children": [].

PageBreak rendered in LibreOffice
PageBreak in LibreOffice 26.8.3.1.

This component has no props.

{
  "type": "PageBreak",
  "props": {},
  "children": []
}

TableOfContents

A table of contents built from the headings. Word fills in the page numbers when the file opens. Has no children: use "children": [].

TableOfContents rendered in LibreOffice
TableOfContents in LibreOffice 26.8.3.1.
Prop Type Nullable Description
title string yes At most 60 characters.
maxLevel integer yes Deepest heading level to list. Default 3. 1 to 3.
{
  "type": "TableOfContents",
  "props": {
    "title": "Contents",
    "maxLevel": 2
  },
  "children": []
}

Was this page helpful?