The Decker File Format

Decker is a multimedia platform for creating and sharing interactive documents, with sound, images, hypertext, and scripted behavior. This guide describes the structure of Decker documents in detail, to facilitate the creation of compatible document viewers and editors.

General Concepts

Decker documents are called Decks, and consist of a series of Cards. Cards in turn contain Widgets. The Decker environment can broadly be in “editing” mode, where widget properties are manipulated interactively, and an “interaction” mode where widgets respond to clicks and other interactions by emitting events and running scripts as applicable.

Widgets, cards, or the deck itself may contain scripts written in the Lil programming language. Scripts have a mechanism for “bubbling” events up along the container hierarchy from a source widget to its containing card, any parents of that card (see below), and perhaps to the deck itself. In response to events, Lil scripts can inspect and manipulate properties of the deck via a series of Interfaces furnished by the application. For more detail on this, see the Decker manual. Lil scripts are not persistent- their local variable bindings are discarded between events. Everything that is persistent about a deck- especially widget values- is captured in the representation described in this guide.

Cards can have a Parent card. If so, they inherit all the properties and widgets of their parent (and its parents, and so on, recursively) unless those properties are overridden. Many cards in a deck may re-use the widgets, scripts, and other properties of a handful of “template” parent cards.

Lil code intended to be reusable across projects can be organized into Modules. From a programming perspective, modules execute once when a deck is loaded (or the module is modified) and each return a dictionary which will be mounted as a global for use by ordinary event-triggered scripts. Modules do not have direct access to the deck or its components, nor do they have direct access to one another. Each module has an independent key-value store which can furnish static data used by the module or allow the module to explicitly preserve its state.


The deck format is designed around several constraints and considerations:


Decks are stored in UTF-8 encoded text files (optionally with a UTF-8 BOM), and have the following structure:

<body><script language="decker">

Where PAYLOAD is the format described in the remainder of this document and RUNTIME is a self-contained sequence of HTML, CSS, and JavaScript sufficient for making the deck self-executing. Anything which is not a web browser can ignore the content of the document following the </script> tag that terminates PAYLOAD.

The PAYLOAD must never contain the literal sequence of characters </script: a web browser would incorrectly treat this as a premature end to the enclosing script tag and thus the payload, corrupting the document.

Applications must support reading documents consisting only of the PAYLOAD section, with no surrounding tags or RUNTIME, for environments where a web browser is not available/desired or when the overhead of the RUNTIME stub is inconvenient. Such a document should be stored with a .deck extension.

Applications must tolerate Windows-style newlines (CR-LF), interpreting them identically to Unix-style newlines (LF only). Emitting Unix newlines when creating documents is strongly recommended.

Data Blocks

The payload may contain fields this guide calls data blocks. Data blocks provide a representation of arbitrary binary data which fits in a JSON string, and has less overhead than a JSON array of numbers. Since APIs for copying and pasting non-textual data are highly heterogenous between operating systems and application frameworks, and many browsers provide limited-to-nonexistent support for this functionality, Decker uses the same data block formats to represent non-textual data in the system clipboard.

Data blocks have a structure like %%TTTFP...:

In the future, the official Decker file format may support additional formats for some block types. If independent forks wish to introduce their own formats it is strongly recommended that they begin with format Z and work backwards alphabetically, to reduce the chance of clashes.

The data block types used by Decker are as follows:


The PAYLOAD consists of a series of lines. Except in {script:ID} chunks, empty lines and lines beginning with a # are ignored as comments, giving users flexibility in annotating documents as they wish. Applications are not required to preserve comments.

A Chunk begins with a line that begins and ends with curly braces {}, indicating the type of the chunk, and spans until the beginning of the next chunk. Some chunk types have an ID which is separated from the chunk type with a colon (:). The following chunk types exist:

Except in {script:ID} chunks, non-comment lines within a chunk are Property Lines consisting of an ID followed by a colon (:). The remainder of the line is interpreted as JSON data. JSON data must escape all forward-slash characters (/ as \/). For example:

name:"AC\/DC Fan Zine"

{script:ID} chunks contain verbatim Lil code and are always terminated by an {end} on its own line. For example:

# this is a Lil comment
on click do
  alert["You clicked a thing!"]

Chunks permit flexible ordering within a document, but often their relative ordering is significant:

IDs and the contents of a {script:ID} chunk can contain nearly any printable ASCII characters. To avoid ambiguity, the following plain characters can be replaced with equivalent escaped sequences of characters:

Plain Escaped Notes
{ {l} Always escape this character.
} {r} Always escape this character.
: {c} Always escape this character in IDs.
/ {s} Escape this character if it is immediately preceded by <.

The {deck} Chunk

The Deck chunk contains a number of optional properties with metadata pertaining to the entire document.

The {card:ID} Chunk

Card chunks always have an ID, which serves as the name of the card. They also may have additional optional properties:

An example of a {card:ID} chunk complete with {widget} section:


one:{"type":"button",text:"Click Me!"}
two:{"type":"button",text:"Check Me Out","style":"check","value":1}

The {widgets} Chunk

The {widgets} chunk is a dictionary of widgets belonging to the preceding {card:ID} chunk, in their drawing order, back-to-front. Each widget is a JSON object with one or more properties.

Some properties are common to all widgets:

Each type of widget has its own additional optional fields:

The {module:ID} Chunk

Module chunks always have an ID, which serves as the name of the module. They also may have additional optional properties:

Modules may contain a {data} chunk containing a dictionary of names associated with JSON values, in the same structure as {widgets} or {fonts}.

Module properties and/or data are always followed immediately by a {script} chunk (with no ID) representing the module body.

An example of a complete {module:ID} chunk:

description:"a utility module for logging"
log:table data.log

mod.put:on _ x do
	into log
	data.log:cols log

mod.get:on _ do

An Example Deck

The following is a simple structurally valid deck, with ... elisions for clarity:

<body><script language="decker">

pusher:{"type":"button","text":"Click Me!","script":0}

on click do
  alert["you clicked the button.\nhooray for you."]