Docs / Guides
The .ofini file format (version 1 and 2)
An OpenFini document is a ZIP archive (MIME type application/vnd.openfini+zip). Everything is plain
JSON plus the original image bytes, so documents can be inspected and repaired with standard tools.
Document.ofini
├─ mimetype "application/vnd.openfini+zip" (stored, first entry)
├─ document.json structure, styles and text
├─ assets/<id>.<ext> original bytes of placed images (png, jpg, webp, gif, avif, …)
├─ pixels/<nodeId>.png one lossless PNG per pixel layer or mask
├─ office/media/<id>.<ext> images of an Office Studio document (only when "office" is present)
├─ office/<kind>/… media of other project kinds; World mesh bodies as office/world/mesh/<sha256>.ofwm
└─ thumbnail.png preview of the first page (≤ 256 px)
document.json#
{
"format": "openfini",
"version": 1,
"id": "d_…", "name": "My Poster", "dpi": 300, "unit": "mm", "studio": "layout",
"createdAt": 1760000000000, "modifiedAt": 1760000000000,
"pages": [ { "id": "p_…", "name": "Page 1", "x": 0, "y": 0, "w": 2480, "h": 3508,
"bg": "#ffffff", "masterId": null,
"margins": {"top":142,"right":142,"bottom":142,"left":142},
"columns": 2, "gutter": 12, "bleed": 35,
"guides": {"h": [], "v": []},
"root": { /* group node */ } } ],
"masters": [ /* same shape as pages */ ],
"assets": [ { "id": "a_…", "name": "photo.jpg", "mime": "image/jpeg", "w": 4000, "h": 3000 } ],
"stories": { "s_…": { "id": "s_…", "story": { "paragraphs": [ … ] }, "defaults": { "char": {…}, "para": {…} } } },
"styles": { "paragraph": { "st_…": { "name": "Body", "attrs": {…}, "char": {…} } }, "character": {} },
"swatches": [ { "id": "sw0", "name": "#000000", "color": "#000000" } ],
"slices": [ { "id": "sl_…", "name": "Hero", "page": "p_…", "x": 0, "y": 0, "w": 800, "h": 400, "format": "png", "scale": 2, "quality": 0.9 } ],
"settings": { "snap": true, "grid": { "size": 32, "subdivisions": 4, "visible": false }, "guidesVisible": true, "facing": false }
}
source (display only)#
"source": { "name": "notes.txt", "format": "txt" } is written when the document was opened from a file and File ▸ Save
still writes it in that format (see file-compat.md). It is metadata for
display: readers must ignore it, and OpenFini never restores a file location from it (a path or handle is not part of the
file). The key is absent for documents created in OpenFini or once the document became an .ofini document.
Nodes#
Every node has id, type, name, visible, locked, opacity (0–1), blend (CSS blend-mode name),
m (the 2×3 matrix [a,b,c,d,e,f] from local to parent space, same convention as Canvas
transform()), fx (live effects) and optional children and mask.
type | Extra fields |
|---|---|
group | children |
rect | w, h, r ([tl,tr,br,bl]), fill, stroke |
ellipse | w, h, fill, stroke |
polygon | w, h, sides, cr, fill, stroke |
star | w, h, points, ratio, cr, fill, stroke |
path | path (see below), rule (nonzero | evenodd), fill, stroke |
text | storyId, w/h (null = artistic text), columns, gutter, insets, vAlign, flowIndex, linked, fill, stroke |
image | assetId, w, h, smooth |
pixel | w, h — pixels live in pixels/<id>.png |
table | cols (widths), rows (minimum heights), cells (rows × cols of {v, rs?, cs?, m?, bold?, align?, fill?, fmt?, borders?, …}), headerRows, headerCols, tstyle (resolved table style), styleId?, colFmt, autoHeight, repeatHeader?, alt? |
chart | w, h, chart (`{type, title, subtitle, data:{categories, series:[{name, values, color?}]}, source:{tableId, range?, seriesIn, header, labelCol} |
adjust | effect ({group, id} — group is adjustment, filter or develop), params |
Paint (fill, stroke fill): {"type":"solid","color":"#rrggbb","alpha":1} or a gradient
{"type":"linear"|"radial"|"conic", "stops":[{"o":0,"color":"#…","alpha":1}], …} with coordinates in unit
bounding-box space (0–1).
Stroke: {fill, width, align:"center"|"inside"|"outside", cap, join, miterLimit, dash, dashOffset}.
Path: {"subpaths":[{"closed":true,"nodes":[{"x":0,"y":0,"ix":null,"iy":null,"ox":10,"oy":0,"t":"smooth"}]}]}
— anchors with absolute control points for the incoming (ix,iy) and outgoing (ox,oy) handles.
Effects (fx): dropShadow, innerShadow, outerGlow, innerGlow, outline, colorOverlay,
blur, each with enabled and its parameters.
Text stories#
A story is a list of paragraphs, each with runs ({text, attrs}) and optional paragraph attrs and
styleId. Run attributes include fontFamily, fontSize, fontWeight, fontStyle, color,
underline, strike, tracking, baselineShift, caps and field (pageNumber, pageCount,
date). The exact schema is in engine-contracts.md.
Tables and charts#
A table node stores its whole model (see layout-tables-charts.md); cell text starting with = is a formula, evaluated at render time. Merged cells: the origin cell has rs / cs, covered cells have m: [row, col]. A chart node stores its definition, never generated geometry; with source set the data comes from the table node with that id in the same document (the stored data is a cache). Document-level tableStyles is { id: { name, style } }. Readers that do not know these types render nothing for them.
Office documents ("office")#
Kinds (Office Suite, additive since 0.10). "office" may carry "kind": "document" (the word processor below;
the field is then omitted, so these files are byte-for-byte what earlier versions wrote), "sheet", "slides",
"board" or another registered app kind (office-suite.md). For any other kind the rest of the object
is that app's model (documented by the app), its media live under office/<kind>/media/<id>.<ext> instead of
office/media/, and the writer stamps "version": 2 (see Versioning). A reader without
an app for a kind keeps the object unchanged and saves it back as it was.
Scenes. A Scene Studio document uses the same container with "kind": "scene" (its studio is "scene"):
the model (version 2: keyframe tangents and nested compositions; version 3: anchor points, nested keyframes, time
remapping of video; version 4: referenced media; every addition optional, so older files load unchanged) is
described in scene-studio.md, and each media item additionally carries
kind (video, audio, image), duration (seconds) and hasAudio; its bytes are stored under
office/scene/media/<id>.<ext>.
Referenced media (scene version 4, written by the desktop app, scene-studio.md):
a media item without file carries path (absolute path of the file), size (bytes), hash ("fp1:" + SHA-256
hex of the size as text, a colon and the first and last MiB) and, when the project was saved to a path on the same
drive, rel (path relative to the .ofini file's folder, /-separated). There is no archive entry for it. Readers
keep such an item without bytes and look for the file; copies written for other people (saveOfini(doc, { embedMedia: true })) store the bytes as usual and drop these fields. No document format bump: OpenFini before
scene version 4 drops the item and its clips when it opens such a file. The File Doctor accepts referenced items.
A document created in or opened by the Office Studio has an "office" object in document.json (its studio is
"office"; the design pages hold one empty page used for the thumbnail). It is the word-processing model of
engine/office/model.js, lengths in points:
"office": {
"type": "office-document", "version": 1,
"meta": { "title": "", "author": "", "subject": "", "keywords": "", "created": "2026-…", "lang": "en-US" },
"page": { "size": "A4", "width": 595.28, "height": 841.89, "orientation": "portrait", "columns": 1, "columnGap": 36,
"margins": { "top": 70.87, "right": 70.87, "bottom": 70.87, "left": 70.87, "header": 36, "footer": 36 } },
"styles": { "Normal": { "name": "Normal", "type": "paragraph", "para": { "spaceAfter": 8, "lineHeight": 1.15 }, "run": { "font": "Calibri", "size": 11 } },
"Heading1": { "name": "Heading 1", "basedOn": "Normal", "next": "Normal", "outline": 1, "para": {…}, "run": {…} } },
"blocks": [
{ "type": "paragraph", "style": "Heading1", "runs": [ { "text": "Intro" } ] },
{ "type": "paragraph", "style": "List", "list": { "kind": "bullet", "level": 0, "id": "l1" }, "props": { "align": "left" },
"runs": [ { "text": "bold", "b": true }, { "type": "break" }, { "type": "image", "media": "img1", "width": 120, "height": 80, "alt": "…" },
{ "type": "footnote", "id": "fn1" }, { "type": "field", "field": "page" } ] },
{ "type": "table", "cols": [150, 150], "borders": { "style": "single", "width": 0.5, "color": "#808080" },
"rows": [ { "header": true, "cells": [ { "blocks": [ … ], "colspan": 2, "shading": "#ffeeaa" } ] } ] },
{ "type": "pageBreak" }, { "type": "rule" }
],
"header": [ /* paragraphs */ ], "footer": [ /* paragraphs */ ],
"footnotes": { "fn1": [ /* paragraphs */ ] },
"media": { "img1": { "id": "img1", "mime": "image/png", "name": "photo.png", "w": 800, "h": 600, "file": "office/media/img1.png" } }
}
Run marks are b, i, u, s, va ("sub" / "super"), color, highlight, font, size (pt) and link.
Covered cells of a merge are simply absent (HTML-style colspan / rowspan). Readers validate the object with
normalizeDoc(), which drops unknown fields and clamps values.
Proto designs#
A Proto Studio design (Labs; concept, ADR 0034)
uses the same container: "studio": "proto" and "office": { "kind": "proto", …model }, media bytes under
office/proto/media/<id>.<ext>. The model is pure JSON with its own integer schema (currently 1):
"office": {
"kind": "proto",
"schema": 1,
"meta": { "title": "Checkout", "created": "2026-12-01T10:00:00Z", "unit": "px", "app": "OpenFini" },
"pages": { "p1": { "id": "p1", "name": "Screens", "ord": "V", "bg": "#f4f4f5", "flows": [] } },
"nodes": { "n1": { "id": "n1", "type": "frame", "name": "Home", "page": "p1", "parent": null, "ord": "V", "w": { "mode": "fixed", "value": 390 }, "h": { "mode": "fixed", "value": 844 }, "layout": { "type": "flex", "dir": "column", "gap": 8 } } },
"vars": { "collections": {}, "items": {} },
"styles": {},
"breakpoints": [{ "id": "base", "w": 1280 }, { "id": "md", "w": 991 }, { "id": "sm", "w": 478 }],
"code": { "links": {}, "tokensFile": null },
"media": { "m3": { "id": "m3", "mime": "image/png", "name": "bag.png", "w": 640, "h": 480, "file": "office/proto/media/m3.png" } }
}
- Nodes are a flat map;
parentis a node id ornullfor a top-level layer of itspage, andordis a fractional order key (collab/fractional.js: base-62 digits, never ending in0); siblings sort byord, then by id. Every field and its CSS meaning: the concept's §3.2 to §3.5. Fields with a default may be omitted (engine/proto/schema.js▸FIELD_DEFAULTS). - Validation (
engine/proto/validate.js) checks types, references (pages, parents, components, variables, styles, collections and modes), parent, component and alias cycles, and the limits (200,000 layers, nesting depth 64, 64 KiB per layer, 20 modes and 2,000 variables per collection, 64 options per variant property, 16 MiB per media item). Interactions and flows that point at a removed layer, and fills whose media is missing, are warnings. The File Doctor,ofini validateandofini inforun it. - Components, variables and styles (task T5, additive within schema 1): an instance's own children are slot
content and
props.<slot>may list child ids per slot; a component binds a slot layer with"bind": { "<slotLayer>.children": "<slotProp>" }. A variable may carryext: { <extendingCollection>: { <mode>: value } }, the overrides of a collection thatextendsits collection (whose modes mirror the base's). Agridstyle's value is a CSS grid definition (cols,rows,areas,autoFlow,dense,gap,rowGap). - Unknown fields are kept (forward compatibility within a schema). A model with a newer
schemaopens read-only; older ones are upgraded step by step byengine/proto/migrate.js. - Stable serialization: writers store the canonical form (
engine/proto/serialize.js): known fields in a fixed order, id maps sorted by id, other keys sorted, soofini unpack --prettygives small diffs.
World scenes#
A World Studio scene (1.4.x; concept, ADR 0035)
uses the same container: "studio": "world" and "office": { "kind": "world", …model }. The model is pure JSON with
its own integer schema (currently 1). Units are meters, +Y is up, right-handed, cameras look along −Z (glTF's
conventions). Binary data lives in parts next to document.json:
- media bytes under
office/world/media/<id>.<ext>(as every Office kind; World media keep theirsizeandhash), - mesh bodies under
office/world/mesh/<hex>.ofwm, named by the SHA-256 of the body, so meshes with the same geometry share one part and an unchanged mesh is an unchanged file in Git.
"office": {
"kind": "world",
"schema": 1,
"meta": { "title": "Bottle shot", "created": "2026-12-01T10:00:00Z", "unit": "m", "up": "+Y", "app": "OpenFini 1.4.0" },
"scenes": { "s1": { "id": "s1", "name": "Scene", "ord": "V", "env": "e1", "camera": "n9", "render": "r1" } },
"nodes": {
"n1": { "id": "n1", "type": "mesh", "name": "Bottle", "scene": "s1", "parent": null, "ord": "V",
"xf": { "p": [0, 0, 0], "r": [0, 35, 0], "s": [1, 1, 1], "ro": "XYZ" }, "mesh": "m1",
"mods": [{ "id": "d1", "type": "subsurf", "on": true, "view": 2, "render": 3 }], "mats": ["mt1"],
"anim": { "xf.r.1": { "kf": [{ "t": 0, "v": 0 }, { "t": 4, "v": 360 }] } } }
},
"meshes": { "m1": { "id": "m1", "name": "Bottle", "hash": "sha256-9f1c…", "size": 1849360,
"counts": { "v": 24576, "f": 24320, "c": 97280, "e": 48896 }, "bounds": [[-0.04, 0, -0.04], [0.04, 0.24, 0.04]],
"attrs": { "uv": ["UVMap"], "color": [], "crease": true, "seam": true, "sharp": false, "weight": [] },
"chunks": ["sha256-…", "…one per 64 KiB of the body"] } },
"materials": { "mt1": { "id": "mt1", "name": "Glass", "model": "pbr", "graph": { "nodes": { "g1": { "id": "g1", "type": "output.pbr", "in": { "roughness": 0.35 } } }, "links": [] } } },
"shaders": {}, "textures": {}, "envs": { "e1": { "id": "e1", "type": "color", "color": "#202024", "intensity": 1 } },
"renders": { "r1": { "id": "r1", "tier": "balanced", "size": [1920, 1080] } },
"timeline": { "fps": 30, "start": 0, "end": 4, "loop": true, "markers": [] },
"media": {}
}
- Maps (
scenes,nodes,meshes,materials,shaders,textures,envs,renders,media) are flat and keyed by id; an id is unique across all of them. Nodes havescene,parent(a node id ornullat the scene root) and a fractionalordkey, as Proto layers. Node types:group,mesh(ameshid or a parametricprim),instance(of, a linked duplicate),camera,light,text3d,shape3d,particles,ref(docand the referenced scene insceneRef),light-probe. Rotations are Euler degrees inxf.rapplied in the orderxf.ro(three.js semantics); a quaternion inxf.q(from glTF) wins until the rotation is edited. - Validation (
engine/world/validate.js) checks types, references, parent cycles, instances that contain themselves, material graph cycles and one output per graph, and the limits of the concept's §3.4 and §3.6 (50,000 nodes, 32 modifiers per node, 512 graph nodes, 32 KiB of shader source, 256 textures of at most 8192 × 8192, HDRIs of 8192 × 4096, 10,000 animation channels, 200,000 keyframes, 1,000,000 particles per emitter, 4 million faces per mesh and 16 million per document, 8 UV and 8 color sets). References that may dangle while editing (modifier pivots, depth-of-field targets, a scene camera that was deleted) are warnings. The File Doctor (world-invalid,world-newer),ofini validateandofini inforun it and also check every mesh body against its entry. - Unknown fields are kept (forward compatibility within a schema). A model with a newer
schemaopens read-only; older ones are upgraded step by step byengine/world/migrate.js. - Stable serialization (
engine/world/serialize.js): known fields in a fixed order, id maps sorted by id, other keys sorted, transform numbers with at most six decimals; serialize → parse → serialize is byte-identical.
Mesh bodies (OFWM)#
Little endian; written by engine/world/mesh-body.js:
magic "OFWM" | u16 version = 1 | u16 flags (bit 0: face sizes are u8) | u32 sectionCount
section: u32 tag (four ASCII letters or digits) | u32 byteLength | bytes, zero-padded to a multiple of 4
POSN f32[3·V] positions VFSZ u8[F] or u32[F] face sizes CORN u32[C] corner → vertex
UV0n f32[2·C] UV set n (0–7) COLn u8[4·C] or f32[4·C] color set n (0–7)
FMAT u16[F] material slot FSMO bitset[F] smooth NORM f32[3·C] custom split normals
ECRE u8[E] crease ESEA bitset[E] seam ESHA bitset[E] sharp
A UV0n or COLn section starts with u16 nameByteLength | u8 kind (0 = u8, 1 = f32) | u8 0 | UTF-8 name, padded to
4 bytes. Bitsets store element i in bit i & 7 of byte i >> 3. Edge attributes follow the canonical edge order:
edges in order of first appearance when walking the faces in order and each face's corners in order (corner k to
k + 1, the last back to the first), each edge once regardless of direction. Writers emit sections in the order
above, then unknown sections in the order they were read. Readers check every length against the counts of the mesh
entry before decoding, reject faces with fewer than three corners, corner indices out of range and trailing bytes,
and keep unknown sections. The body's SHA-256 is its name (hash, "sha256-<hex>"); chunks are the SHA-256 of its
64 KiB slices, used by collaboration to send only the chunks a peer lacks.
Comments#
"comments" (optional, additive since 0.7.0, no format version bump: older readers ignore it) holds the comment threads
of the document (collaboration.md). The key is absent when there are none.
"comments": [
{
"id": "cAbC…", "author": "<22-char member id>", "nick": "Mia", "color": "#0090ff", "ts": 1760000000000,
"anchor": { "kind": "node", "node": "n_…", "page": "p_…", "quote": "Hero box" },
"resolved": false, "resolvedBy": "Hana", "resolvedAt": 1760000000000,
"messages": [ { "id": "cAbC…-0", "author": "…", "nick": "Mia", "color": "#0090ff", "text": "Bigger?", "ts": 1760000000000,
"edited": 1760000000000, "deleted": false, "mentions": ["<member id>"], "ai": true } ]
}
]
Anchor kinds: doc; page (page); node (node, page); region (page, rect {x,y,w,h} in page coordinates);
text (Office studio: path = JSON paragraph path, from, to offsets, quote); line (Code studio: path = file,
line, endLine, quote). element (Code studio: path = HTML file, sel = element-sibling indexes from the root such as 0/1/3, elem = parser id, quote).
Migration note: sel was added with 0.10 (additive; older readers drop it and keep the thread). ai: true on a thread
or a message (added after 1.0.0, additive, no format version bump) marks text written by the Vibe assistant (still
signed "nick": "Vibe (AI)"); every comment UI shows an "AI" badge next to the name. Older readers drop the field and
keep the comment; comments without it are shown as written by people. Threads from earlier versions load unchanged;
anchors without pin fall back to the layer's top right corner. Messages without nick are shown as "Unknown author".
Text is plain text (never HTML). Readers validate every thread with
collab/comments.js ▸ normalizeThreads (unknown fields, wrong types and oversize values drop the thread); the document
loader itself only keeps objects with an id (at most 2000). Comments are not undoable steps; they mark the document as
changed.
Named versions are not in the file. Versions (Collaboration ▸ Versions) are complete .ofini snapshots stored on
the device (IndexedDB keys versions.index, versions.data.<id>, versions.thumb.<id>, encrypted by the app lock).
Versioning and migration#
document.json carries "version": N. The code lives in app/src/core/ofini-migrate.js (pure, tested in tests/core/ofini-migrate.test.js):
- Old files always open.
migrateDocumentJsonupgrades a document from its version toFORMAT_VERSIONone step at a time (MIGRATIONS[n]turns version n into n + 1). Files without a version are format 0. The upgrade happens in memory; the file on disk is untouched until you save, and the toast on open says what changed. - Newer files open best-effort. A file from a newer OpenFini opens with what this version understands (unknown fields are ignored and kept in memory), the user is warned, and the first Save asks for confirmation because saving could drop data this version cannot see (use Save As to keep the original).
- Writers stamp the oldest version that can represent the document (
ofini-migrate.js ▸ writeVersion): 1 for everything except Office documents of a kind other than"document", which are 2. Version 1 → 2 needs no conversion (an absentoffice.kindmeans"document"); the bump exists so OpenFini 0.9 and earlier treat a spreadsheet, presentation or whiteboard as a newer file (warning before Save) instead of an empty text document. - Changing the format (checklist): bump
FORMAT_VERSION, add the step toMIGRATIONS, add a frozen sample of the olddocument.jsonto the tests (the version 1 sample is there already), describe the change here. Never rename zip entries without a migration that is told about the entries.
Compatibility#
- Readers must ignore unknown fields.
- Unknown node types should be preserved on a best-effort basis and rendered as nothing.
versionis incremented only for changes that older readers cannot ignore.- Colors (
color) are RGB in the document's working space (sRGB unlesssettings.color.rgbsays otherwise). Additive color management fields (no version bump, older readers see the RGB preview):settings.color = { mode: "rgb"|"cmyk", rgb: "srgb"|"display-p3"|"adobe-rgb", cmyk: <asset id>|null, cmykName, intent: 0-3, bpc }; solid paints, gradient stops and swatches may carrycmyk: [c, m, y, k](percent, the native value) andspot: "Name"; a loaded CMYK ICC profile is an asset with mimeapplication/vnd.iccprofile, stored asassets/<id>.icc. See color-management.md.
Edit on GitHub → docs/file-format.md