Skip to Content
Fetlar
Reference

JSON output schema

The document model that fetlar -t json prints, block by block.

fetlar FILE -t json prints the whole document as typed blocks. The same model is used for Word, Excel, PowerPoint, CSV, TSV and HTML.

{
  "kind": "docx",
  "pages": [
    {
      "page": 1,
      "title": null,
      "blocks": [
        { "type": "heading", "text": "4.2 Payment terms", "rtl": false, "level": 2, "page": 1 },
        { "type": "list_item", "text": "Approve the budget", "rtl": false, "level": 0, "ordered": true, "label": "1.", "page": 1 },
        { "type": "table", "text": "Item | Amount\nSalaries | 1,234,567.89", "rtl": false,
          "rows": [["Item", "Amount"], ["Salaries", "1,234,567.89"]], "page": 1 }
      ]
    }
  ]
}

Top level

KeyMeaning
kindthe kind of file: docx, xlsx, pptx, csv, tsv or html. An old .xls has kind xlsx
pagesa list of pages
warningsoptional list of warnings, for example when a workbook was cut at the cell limit

Pages

A page is the whole Word document, one visible Excel sheet, or one visible PowerPoint slide.

KeyMeaning
pagethe page number, from 1
titlethe slide title, or the sheet name where there is one. Otherwise null
blocksa list of blocks

Blocks

Every block has type, text and rtl (true for right-to-left text).

typeExtra keys
headinglevel
paragraph
list_itemlevel (nesting, from 0), ordered, label (the real number or bullet, such as 1. or (b))
tablerows: a list of rows, each a list of cell text
charttitle, rows
notespeaker notes
footnote
header, footer
imageonly with --images. The part name inside the file

page on a block is the Word page it starts on, when the file records page breaks. A table's text is its rows joined with | and new lines. Number columns in a CSV table are marked for right alignment.

Compare output

fetlar diff -f json has its own shape: a kind and a list of changes, each with a kind (such as edited or cell_changed), a location and the old and new values. Edited Word paragraphs also carry spans, a list of equal, delete and insert pieces. See Comparing files for an example.

On this page