Data types and file formats

The file kinds, value types and workflow file format the tools read and write.

File kinds

The site sorts every file into a kind. Each tool lists the kinds it accepts (the accept field in the catalog), and workflow input and if blocks use the same kinds.

For example, scan.pdf is a pdf, photo.webp is an image, and report.docx is a docx.

Kinds and the extensions that give them
KindExtensionsNotes
pdfpdfAlso any file with the PDF MIME type.
imagepng, jpg, jpeg, webp, gif, bmp, avifAlso any image MIME type except SVG and TIFF.
docxdocxWord documents.
xlsxxlsx, xls, csvSpreadsheets. CSV files are in this kind (see below).
pptxpptxPowerPoint presentations.
htmlhtml, htmWeb pages.
texttxt, md, csv, jsonPlain text. CSV and JSON are also listed here, but a CSV file is tried as xlsx first.

Some feature ops, such as feature:convert, accept any file. They name the files they cannot handle in their error. Tools that accept only some kinds also say so in the error when given another kind.

Audio and video files, SVG and TIFF images are not in the list of kinds above, so they have no kind in workflow input and if blocks.

How a file's kind is decided

The kind comes from the file name extension. For PDFs and images, a matching MIME type also works.

  1. The kinds are tried in this order: pdf, image, docx, xlsx, pptx, html, text.
  2. The first kind that matches wins. That is why a CSV file counts as xlsx in workflow tests.
  3. A file that matches none (for example SVG) has no kind. An input block that names a kind drops it, and it passes a type test only with !=.

Value types in text pipelines

A text operation reads and writes one of three value types, and the steps of a version 1 pipeline must agree on them. text is a string. bytes is a byte array, which is what hashes take. json is any JSON value. A file read as bytes is not decoded; a file read as text must be valid UTF-8, and a json input must parse as JSON. A text task writes a text result as a plain text file, a json result as a JSON file, and a bytes result as a binary file.

File objects in the API

Everywhere the API takes files, each entry is a File, a Blob with a name, or a plain { name, bytes } object where bytes is a Uint8Array or ArrayBuffer. Results come back as File objects. The type of each result is set from its extension. A name is required for every file; names must be unique within one run when you use the command line.

Output names and types

Each tool names its results; the catalog and each tool's page say how. For example, the rotate tool writes name-rotated.pdf. Text operations keep the name of the file they read. A result is never written over one of your input files: outputs are new files.

Workflow files

A workflow is a JSON file: a version 2 graph or a version 1 text pipeline. Its text is limited to 256 KB in UTF-8. The format, with its node types and rules, is in Workflow API, and what a run does with the files is in Workflow semantics. A minimal version 2 file:

{
  "version": 2,
  "name": "Keep PDFs and rotate them",
  "nodes": [
    { "id": "in", "type": "input", "x": 0, "y": 0, "config": { "type": "any" } },
    { "id": "rot", "type": "task", "x": 260, "y": 0, "config": { "tool": "rotate", "options": { "angle": 90 } } },
    { "id": "out", "type": "output", "x": 520, "y": 0, "config": {} }
  ],
  "edges": [
    { "from": "in", "fromPort": "out", "to": "rot", "toPort": "in" },
    { "from": "rot", "fromPort": "out", "to": "out", "toPort": "in" }
  ]
}

Note that this example sends every file to the rotate tool, which takes PDFs only. Add an if block or a pdf input block to keep the other files out.

Text and encoding

Text operations and the text feature ops read files as UTF-8 and fail on bytes that are not valid UTF-8, rather than substituting characters. Use a text file in UTF-8 when you chain these operations.