The cello format
The cello file format: a spreadsheet stored as one HTML file, with typed data, named formulas, views and a pinned viewer. Made from SPEC.md in the cello repository.
Oct 4, 2026 · @Adam (Brault) Avenir
Overview
cello is a spreadsheet stored as one self-contained HTML file: typed CSV data, named formulas, and any number of styled views, with no server and no network access. Open it in the Cello app, or in a browser as a copy named .html, to view and print it. Open it in a text editor, or hand it to an agent, and you get plain CSV, JSON, and templates.
The core idea is separating data from presentation. The data carries meaning (types, units, tags). Views decide how it looks. An invoice, a summary, and a plain table grid are three views of the same data.
Goals
- One file. Its contents are a complete web page, so a copy named
.htmlopens in any current browser from disk (file://), with no install and no server. - Data is canonical CSV text; the schema is a Data Package v2 descriptor. Export produces a conformant Data Package with no conversion.
- Formulas are named, reference columns by name (never A1), and are pure and deterministic.
- Semantics (types, units, categories, tags) live in the schema, never in cell formatting.
- Views are a query, a template, and a stylesheet. Print output comes from CSS paged media.
- Agents and diffs work on it directly: line-oriented data, stable serialization, data blocks first in the file.
- Secure by construction: CSP pins the one runtime script by hash, blocks all network access, and formulas are never passed to
eval.
Non-goals for v0.1
- Excel compatibility. Excel import and export are one-way conversions (see
cello importandcello export), not a shared format. - A1 references, merged cells, per-cell formatting, macros
- Editing inside the file itself. The file is a read-only view. People and agents change it as text and check it with the CLI; editors (
cello edit, the desktop app, cello.sh) are separate programs that read and write the format. - Several people editing one file at once. The format has no merge rules of its own; cello.sh relays changes between the people who have a sheet open.
Principles
- If something means something, it goes in the schema or the data. If it only changes appearance, it goes in a view.
- Formatting numbers for display is a view concern. The formula language has no
TEXT()function. - Every file is valid as plain text first and as an app second.
- The spec reuses existing standards wherever one exists and only defines what they leave out.
The key words MUST, SHOULD, and MAY are used as in RFC 2119.
Standards cello builds on
cello defines three things the standards below leave out: formulas over named columns, tag exposure for styling, and views. Everything else is borrowed.
| Standard | What cello uses it for |
|---|---|
| Data Package v2 (OKFN, June 2024) | The package descriptor, Data Resource, and Table Schema: field types, categories, list fields, constraints, missingValues, primaryKey, foreignKeys. The embedded descriptor is a valid Data Package descriptor. |
| RFC 4180 | CSV syntax for data blocks, with the canonical form defined in Data blocks below. |
| OpenDocument 1.4 Part 4 (OpenFormula) | Semantics for every formula function that shares a name with an OpenFormula function, except where this spec says otherwise (null handling, lists). |
| HTML Living Standard | File container. Data lives in non-executing <script> blocks, which the parser treats as raw text. |
| CSP Level 3 | Pins the runtime script by SHA-256 hash and blocks network access. |
| CSS Paged Media | Print layouts for views: @page, page breaks, margins. |
ECMA-402 (Intl) |
Number, currency, percent, and date display formatting in views. |
CSVW's note on embedding tabular metadata in HTML uses script blocks the same way, which is precedent for the container approach. cello does not use the CSVW vocabulary.
File format
A cello file is a UTF-8 HTML document with a fixed set of blocks in a fixed order. Everything a person or agent edits is raw text inside <script> or <style> elements, so it round-trips byte for byte.
- Extension:
.cello, so the file opens in the Cello app rather than a browser. Tools also accept the older.cello.html, andcello export <file> <out.html>writes a copy a browser opens. Encoding: UTF-8, no BOM. Line endings: LF. - The structure is exactly the canonical layout:
<html lang>, then<head>holdingmeta charset, the CSPmeta(right after it), the viewport and generatormeta, andtitle; then<body>holding the blocks. Each element carries only the attributes shown, socello checknever approves a file a browser would read differently (for example, a CSPmetaoutside<head>is ignored by browsers, and asrcon the runtime tag would load a different script). - A conforming file contains only the elements listed below. Readers ignore anything else; writers drop it;
cello checkreports it as an error.
Canonical layout
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Security-Policy" content="…see Security model…">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="generator" content="cello 0.1">
<title>Invoice 2026-014</title>
</head>
<body>
<noscript>…fixed fallback, see below…</noscript>
<script type="application/json" id="cello-package">
{ …Data Package v2 descriptor… }
</script>
<script type="text/csv" data-cello-path="lines.csv">
…CSV…
</script>
<script type="text/x-cello-template" data-cello-view="invoice">
…template…
</script>
<style data-cello-view="invoice">
…view CSS…
</style>
<script data-cello-runtime="0.9.15">…runtime…</script>
</body>
</html>
Blocks
| Element | Count | Content | Who edits it |
|---|---|---|---|
meta[http-equiv=Content-Security-Policy] |
exactly 1, first after charset | CSP with the runtime hash | tooling only |
script[type="application/json"]#cello-package |
exactly 1 | package descriptor | people, agents, tooling |
script[type="text/csv"][data-cello-path] |
1 per table resource | CSV; attribute value equals the resource path |
people, agents, tooling |
script[type="text/x-cello-template"][data-cello-view] |
1 per custom view | view template | people, agents, tooling |
style[data-cello-view] |
0 or more per view | view CSS; value is a view name or * for all views |
people, agents, tooling |
noscript |
exactly 1 | fixed fallback | tooling only |
cello-snapshot |
0 or 1, right after noscript |
drawn copy of the front view, written by export | tooling only |
script[data-cello-runtime] |
exactly 1, last in body | runtime JS; attribute value is the runtime version | tooling only |
Order in <body>: noscript, the snapshot if any, package, CSV blocks in descriptor resource order, then for each view in descriptor order its template followed by its styles, then grid styles, then * styles, then the runtime. <title> mirrors the descriptor title; the descriptor wins on conflict.
Raw-text rules
- Readers MUST read blocks with
textContent, neverinnerHTML. - Block content starts with
\nafter the opening tag and ends with\nbefore the closing tag. Readers strip exactly one of each. - These sequences are forbidden, case-insensitive. In
<script>blocks:</script,<script,<!--. In<style>blocks:</style. They would end or corrupt the block. - The JSON writer escapes every
<as\u003c, so the descriptor can hold any string. - CSV, template, and style writers MUST reject content containing a forbidden sequence, with an error naming the table, row, and field (or the view). There is no escape syntax in v0.1; see Open questions.
No-JS fallback
Browsers hide <script> elements by default, but CSS can show them. The fixed noscript block makes the raw CSV readable with JavaScript off:
<noscript>
<style>script[type="text/csv"]{display:block;white-space:pre;font:13px/1.4 ui-monospace,monospace;margin:1em;padding:1em;border:1px solid #ccc;overflow-x:auto}</style>
<p>This is a cello file. JavaScript is off, so here is the raw data.</p>
</noscript>
Some viewers run no script even with JavaScript on: a phone's mail app previewing an attachment, for one, applies its own policy that blocks the file's inline script, and the page would be blank. So an HTML export (cello export, and Export in the editor) puts a <cello-snapshot> block after the noscript block: the front view (see defaultView) drawn as cello render draws it, with the built-in pieces' CSS. The runtime removes the block before it draws anything, so where the script runs the snapshot is never seen. Any save leaves it out, so a saved file never carries a stale copy; export again to redraw it. A snapshot holding <script, <!--, <iframe, <object, <embed, or an on…= attribute is an error. Export also brings an older runtime up to the current one, since only a runtime that knows the block removes it.
Size
Files SHOULD stay under 10 MB. The runtime MUST stay responsive at 100,000 stored cells and SHOULD warn above that.
Package descriptor
The #cello-package block is a Data Package v2 descriptor. Every cello addition lives under a property named cello, at package, resource, or field level, so standard Data Package tools ignore it and cello export can write the descriptor out verbatim as datapackage.json.
Writers emit the descriptor as JSON with 2-space indent, except that any object or array whose line (its key, the one-line value, and a trailing comma, not counting indentation) fits in 100 characters stays on one line, with spaces inside braces: { "name": "date", "type": "date" }. Keys keep the order read, new keys are appended, and every < is escaped as \u003c. This keeps one field or name per line for diffs. Untouched descriptors are written back from their original text.
Package
$schemaSHOULD behttps://datapackage.org/profiles/2.0/datapackage.json.nameandresourcesare required, as in Data Package. cello also requirestitle.cello.versionMUST be"0.1". A reader MUST refuse a file whose major version it doesn't support, and SHOULD warn on a newer minor version.cello.names: package-level named values (below).cello.views: view definitions (see Views).cello.nav, optional, pins a bar of links to views at the top of every view:"all"(every view, in order) or view names separated by spaces; the view shown is marked, and the bar is left out of print,cello viewtext and a view shared on its own.cello.settings, optional, names inputs (separated by spaces;name:rowdraws one as buttons,name:dropdownas a menu) whose controls sit in a row at the top of every view, under the bar: drawn as ac-settingspiece would draw them, with a choice of five or fewer as buttons (asswitchdoes), so changing one is a what-if or an edit as any view control is.cello.defaultViewnames the view shown on open. Without it, a file opens on its index view (below), else its first view, else the grid.
Resources
Each table is one resource with:
namematching^[a-z][a-z0-9_]*$(stricter than Data Package, so it works as a formula identifier)type: "table",format: "csv",mediatype: "text/csv",encoding: "utf-8"pathequal to thedata-cello-pathof exactly one CSV block. Writers SHOULD use<name>.csv.schemaas an inline object. External schema paths and URLs are not allowed.- no
dataproperty and nodialect(the canonical CSV form is fixed) - optional
cello.computed: computed columns (below)
Schema
fieldsMUST list every CSV column, in CSV order. The CSV header row MUST equal the field names exactly.- Field
namematches^[a-z][a-z0-9_]*$and is nottrue,false, ornull. Fieldtitleis the display label. - Supported types:
string,number,integer,boolean,date,datetime, andlistwithitemTypeofstring,number,integer, ordate. Other Table Schema types load as strings, andcello checkreports them as unsupported. - Supported constraints:
required,unique,minimum,maximum,minLength,maxLength,pattern,enum. A violation flags the cell; it never blocks an edit. categories(andcategoriesOrdered) on string or integer fields are supported and drive tag exposure.missingValuesdefaults to[""]. Matching values load as null.primaryKeyandforeignKeysare validated bycello check.
Field extension
field.cello may contain:
unit: an ISO 4217 currency code ("USD"),"percent"(stored as a fraction, 0.0875), or any short free-text unit ("kg","hours"). Units are semantics; views use them for default formatting.values: forlistfields, the allowed items. Table Schema v2 can't putcategorieson lists yet, so cello adds this.expose:falsesuppresses attribute exposure for a field that would otherwise be exposed (see Semantic fields and tags).
Computed columns
resource.cello.computed is an array of derived columns. They are never stored in CSV. Each entry has name, formula, and optional title, type, unit. name shares the namespace of that resource's fields. The grid shows computed columns after stored columns. cello export --materialize writes them into the CSV and schema as ordinary fields.
Names
package.cello.names maps identifiers to scalar values. Each entry has either value (an input a person edits) or formula (computed), never both, plus optional title, type, unit. A string input may also list categories, its allowed values, which a view control offers as a list (see c-input).
"names": {
"client": { "title": "Client", "type": "string", "value": "Acme Co" },
"tax_rate": { "title": "Tax rate", "type": "number", "unit": "percent", "value": 0.0875 },
"subtotal": { "formula": "SUM(lines.line_total)", "unit": "USD" },
"total": { "formula": "ROUND(subtotal * (1 + tax_rate), 2)", "unit": "USD" }
}
Names and resource names share one namespace. Field and computed column names only need to be unique within their own resource; other resources reach them as table.field. A duplicate in either scope is a validation error. Input value types: JSON number, string, boolean, or an ISO 8601 string when type is date or datetime.
Inputs table
A file may keep its inputs in one table instead of as names. The resource says "cello": { "role": "inputs" }, and each row becomes an input name: its name column (an identifier, required) is the name, and the row's other columns describe it. A file usually has one inputs table; it may have more (each model link brings its own; see Sharing a model). Their names share the namespace of every other name.
| Column | Meaning |
|---|---|
name |
The input's name in formulas. |
title (or label), group |
For people and views. |
labels |
Themes the input belongs to, any number, separated by | or commas (pricing|growth). The inputs panel can be grouped by them, and leverage lists them. |
type |
number (the default), integer, boolean, date, datetime, string, or case for a case setting. A boolean row's cells read true/false, or 1/0 in number columns; editors draw it as a checkbox, and a row with choices as a list. |
unit |
The input's unit, as for names. |
value |
Its value when it doesn't vary by case. |
| one column per case | Its value in that case. |
override |
A value that holds in every case. |
pick |
A case this row is held to, whatever case is in force. |
min, max |
Limits. |
dial |
The dial this row follows instead of the main setting (see dials below). |
section, confidence |
Optional notes the inputs panel can group by. |
choices |
For a string or case row: its allowed values, separated by |. |
when |
A yes/no formula: while it is no, the input is off (see below). |
Any other column is a note, which views and case formulas can read.
Cases are declared on the resource: "cases": { "by": "scenario", "cases": ["low", "skeptic", "base", "high"], "derive": { "skeptic": "(base + low) / 2" } }. by is the case setting: a row of type case, or an input name, whose allowed values are cases. derive gives a formula for a case, evaluated in the row's context; it may read only the row's stored columns and may not use @.
A table's cases may also carry words, other choices of the setting each standing for a case ({ "custom": "projected" }), and dials: settings some rows follow instead of by, each an input with a list of choices and a map of its own words to cases ({ "spending": { "lean": "optimistic" } }; an empty map means its words are the cases). A row follows the dial its dial column names. A dial holding one of its words, or a case, chooses that case; holding anything else (such as "from case"), it follows by. In x@word, a word that is both a case of by and a choice of a dial belongs to by; set a dial by name, x@(spending = "lean").
An input's value is the first of these that gives one: override; the column of the case named in pick, else its derive formula; the column of the case its dial (or by) chooses, else its derive formula; value. A derive formula applies only to a row with a value in at least one case column. A case setting, and any row with choices, doesn't vary by case: it reads override, then value. The result is typed by type. A number outside min or max is an error in validation, and edits, what-ifs and @ that would put it there are refused (@ gives #NUM).
An input may apply only some of the time: while Series A is off, its inputs don't matter. A row's when column, or an entry in the resource's "when": { "Series A": "series_a_on", "work_hosting": "work_on" } naming its group or the input itself, is a yes/no formula; while one gives no (false, or 0 for a 1-or-0 switch) the input is off. Its values stay in the file and its formulas read them as ever; what changes is what's shown: the inputs panel puts what's off last, folded, saying why, leverage leaves it out, and the outline marks it. An entry applies to its group, or its input, in every inputs table of the file, so the file that links a model says when the model's groups or rows apply; the edit script's when line sets one. A condition that errs, or gives anything but yes or no, leaves its inputs on and is a warning in validation, as is an entry naming a group no input is in. An input a condition reads is never off, so the switch stays in sight.
Each row is shown in its own unit wherever the row is shown: a number column of the inputs table with no unit of its own takes the row's unit.
Links to other files
A file can bring in something worked out inside another cello file: one value, or a table made from one of its tables. Only the result is stored, so a file can use a salaries sheet's total without holding a single salary, and it still opens anywhere on its own. The runtime treats linked tables and values like any others; cello's tools (the CLI, the editor, the app) read the other file and keep the copy current.
A linked value is an input name with link. Its formula is evaluated in the source, with no row context, and must give one value:
"payroll": { "title": "Payroll", "value": 400000, "type": "number",
"link": { "from": "../hr/salaries.cello", "formula": "SUM(staff.salary)", "mode": "live", "copied": "k3x9q…", "at": "2026-09-28T17:02:11.000Z" } }
A linked table is a resource with cello.link. query picks rows of one of the source's tables as a view query does (from, and optional where, group, sort, limit); columns maps this file's column names to formulas over each row, or over each group when group is given (group keys come first, and columns is then required). Without columns, every column of the source table is brought, computed ones as plain values, with the source's settings and primary key.
"cello": { "link": { "from": "../hr/salaries.cello", "query": { "from": "staff", "group": { "department": "department" } },
"columns": { "total": "SUM(salary)" }, "mode": "pinned", "tell": true, "copied": "…", "at": "…" } }
fromis a path relative to the file's folder ending.celloor.html, or anhttp(s)share link (seecello share) on a Tailscale network (*.ts.net,100.64.0.0/10) or this machine. Anything else is refused before it is read. On cello.sh, a relative path is read from the sheet's folder in its space.mode:livecopies follow the source by themselves while the file is open in the editor;pinnedones wait for the person (orcello refresh).inputs(optional) gives some of the source's input names other values while the link is worked out, such as{ "scenario": "low" }, so several links can read one source under different settings. Values are typed as the source declares the name, must be in itscategorieswhen it has them, and only input names can be set, never worked-out ones. The source file is not changed.copiedis a fingerprint of the stored copy, so a tool tells whether the source has changed with one comparison, and edits made outside cello's tools are caught too.atis when the copy was made.- A linked table's stored cells and columns can't be changed in this file (the edit step is refused); it may have computed columns of its own, which are kept across refreshes. Unlinking keeps the data as an ordinary table.
- Nothing is read until the person allows it. A file names its own sources, and one received from someone else could name any cello file on the disk, or any address. So cello's tools read a source for a file only once the person has allowed that source for that file: by making the link, by
cello refresh --allow, or with Allow in the editor. The allowed pairs are kept per user in~/.config/cello/allowed-links.json(shared by the app and the CLI). Until then the file shows its last copy, and the editor says what it's waiting for. Share links are fetched without following redirects. - A column of a grouped link must give one value per group (
SUM(…),COUNT(…), …), never the group's list of values, so the link can't carry the rows it leaves out. A group of one still shows that one row's values; group by something coarser when that matters. - Links are one-way. The source is never changed, and learns of a link only if it says
"tell": true: then<source>.links, a JSON list beside the source, names the linking file and the columns and names its link formulas use, so an editor of the source can warn before deleting them. - A refresh reads renames recorded in the source's change log (
<source>.log) sinceat, and rewrites the link's formulas to match, so a renamed column doesn't break the link. For a whole copy, the column is renamed in this file too, formulas and all. - When the source itself is renamed or moved, only
fromchanges:relinkin an edit script,cello relink, or Change source… in the editor. The new source is read first and must offer what the link needs (as making the link checks); the copy, settings andatstay, so the next refresh says what the new source changes. On cello.sh, renaming or moving a sheet or folder rewritesfromin the sheets that read it, by whoever made the change, where they can edit those sheets.
Sharing a model
A model link brings the part of another file's math that its shared inputs reach, so those inputs can be changed in the linking file and the results follow.
The source says what may travel, in package.cello.shared: inputs, names of inputs another file may change, and tables, tables whose rows may travel. Nothing else marks anything shared.
Folding starts from the results asked for (names, or table.column) and walks back through what they read:
- An input is reached when it is shared. When a case setting is shared, an input that varies by it (it has a value in a case column, and no
overrideorpick) and that the results read must be shared as well; otherwise the link is refused, naming those inputs. - A name or computed column is reached when anything it reads is reached.
- Reached formulas arrive as formulas. Within them, a name nothing reached feeds arrives as a fixed name holding its value; any other part that reads nothing reached and doesn't depend on the row, and names no name, is replaced by its value, worked out in the source. Computed columns that aren't reached arrive as stored columns of values.
- A value arriving fixed may read a table that isn't shared only through
SUM,AVERAGE,COUNTorCOUNTAover two or more of its rows (zero rows reveal nothing; exactly one is refused). Any other read (a lookup,INDEX, a row's cell, a total of one row) refuses the link, naming the table. - A table arrives, with its primary key and the columns needed, when reached math reads it row by row or as a whole column. A table not listed as shared is never carried this way: the link is refused, naming the table and the formula.
- Reached inputs arrive as rows of a prefixed copy of the inputs table they came from, with the columns that describe them, their case columns, and the
deriveformulas, so cases still switch. When the linking file has an input (of its own, or from another model) whosecategoriesinclude every case of a shared source setting, and whose other choices are the source's words or words the linking file maps to those cases, the copy's cases follow that input instead of a copy of the setting, and take its words too. A shared dial follows an input of the linking file with the same name and choices (or the only one with those choices). The copied rows keep all their columns but the case columns when the cases don't travel. A copied setting whose cases share a name with any other input'scategoriesin the linking file is refused, sincex@casewould be ambiguous. INPUT()in reached math can't be folded and is refused.@travels when the cases and inputs it sets travel.- When the source itself holds a model link to a file the linking file also links as a model (the same file, its path read from each file's folder), the source's copy reads through the linking file's copy: its names and tables are read as the linking file's, which count as reached, and none of them arrive. The linking file's link must ask for every result the source's link asks for; otherwise the link is refused, naming the results to add. Tools SHOULD offer to add them to the linking file's link first.
A name that arrives as a value carries "fixed": true: it can't be set in the linking file, and a refresh replaces it. Tools SHOULD let an owner preview a model link before anyone makes it: which inputs could be changed, which names and columns arrive as formulas, which tables' rows go, which numbers arrive fixed, and which tables are read only as totals.
Every arriving table and name is prefixed with the link's name and an underscore (rev_price, rev_years), and marked with "model": "<name>" (on the resource's cello, or the name's entry). package.cello.models records each link: { "rev": { "from": …, "results": […], "at": …, "inputs": { "names": {…}, "tables": {…} } } }, where inputs is the source's inputs as last copied. A model's tables other than its inputs tables can't be edited in the linking file. A refresh folds again and replaces the model's tables and names; an input cell or value that differs from the last copy was changed here and is kept. Removing the record and the marks ends the link and keeps what arrived as the file's own.
Tools SHOULD warn when a value arriving fixed, or the step between consecutive rows of a column arriving fixed, equals one non-zero row of a numeric column of a table it reads but doesn't share, since a reader could learn that row.
Data blocks
Readers are lenient and writers are strict: any RFC 4180 CSV loads, and every write produces one canonical byte sequence. Serializing a parsed canonical block MUST reproduce it byte for byte.
Reading
- The CSV text is the block content after the raw-text newline strip. Comma delimiter, double-quote quoting,
""for a literal quote. LF or CRLF accepted. - Row 1 is the header and MUST equal the schema field names in order.
- A header-only block is a valid empty table. An empty block is an error.
- Whitespace is significant. Nothing is trimmed.
- A row with the wrong number of cells is an error in
cello check. The runtime pads or truncates it with null and flags the row. - A value that doesn't parse as its field type keeps its raw text, is flagged invalid, and evaluates to
#VALUEin formulas.
| Type | Accepted forms |
|---|---|
number |
-?\d+(\.\d+)?([eE][+-]?\d+)?; NaN, INF, -INF load but cello check warns |
integer |
-?\d+ |
boolean |
true, True, TRUE, 1 / false, False, FALSE, 0 |
date |
YYYY-MM-DD |
datetime |
YYYY-MM-DDThh:mm:ss(.sss)? plus optional Z or ±hh:mm. Without an offset it is treated as UTC. |
list |
items split on the field delimiter (Table Schema default ,; cello writers SHOULD use ;), each parsed as itemType |
string |
as is |
The empty string and null are the same value in v0.1, because missingValues defaults to [""].
Canonical writing
- Rows separated by LF, no trailing newline in the CSV text, header row first.
- In a one-column table, a null row is written as
"", so it can't be read as a trailing newline. - Quote a value only if it contains
,,", LF, or CR, or starts or ends with a space or tab. - Numbers: shortest round-trip decimal (JavaScript
String(n)for finite values), no grouping, no leading+. Integers have no decimal point. - Booleans:
true/false. Dates:YYYY-MM-DD. Datetimes: as stored, including the offset if present. - Lists: items joined by the field delimiter, in stored order.
- Null: empty, unquoted. When a field's
missingValuesdoesn't include"", null is written as its first entry instead. - Invalid values are written back exactly as their raw text. A write never loses what a person typed.
- Row and column order are data. Writers never reorder either unless a person or tool explicitly did.
Semantic fields and tags
Meaning that Excel users express with fill colors lives in fields, and the renderer exposes it as data-* attributes so CSS can style it. Tags are just a list field; conditional formatting is just a computed boolean.
Exposure rules
On every rendered row element (grid rows and c-each elements in views), the renderer sets data-<field name> for:
| Field kind | Attribute value |
|---|---|
string or integer field with categories |
the value, e.g. data-status="sent" |
boolean field or computed column |
true or false |
list field with itemType: "string" |
items joined by single spaces, e.g. data-tags="billable review", so [data-tags~="review"] matches |
any other field with cello.expose: true |
the canonical text of the value |
- Null values omit the attribute.
cello.expose: falsesuppresses a field that would otherwise be exposed.- Items of an exposed list field MUST match
^[A-Za-z0-9_-]+$.cello checkenforces this. - The runtime also sets
data-table="<resource>"anddata-row="<0-based index>"on row elements, anddata-invalidordata-error="<code>"where applicable. In the grid, each cell also getsdata-field="<name>". - Reserved field names, in addition to
true,false,null:row,table,field,invalid,error, and anything starting withcello.
Tags convention
A field named tags with type: "list", itemType: "string", delimiter: ";", and cello.values listing the allowed tags. This is a convention, not a requirement. Tagging a row is adding a word to one CSV cell, and cello check rejects tags outside cello.values.
Replacing conditional formatting
A computed boolean plus a CSS rule replaces a conditional formatting rule, and unlike Excel's version the condition is visible, queryable, and survives export.
{ "name": "overdue", "type": "boolean", "formula": "AND(status <> \"paid\", due < as_of)" }
[data-tags~="review"] { background: #fff4c2; }
[data-overdue="true"] .due { color: #b00020; font-weight: 600; }
Formula language
Formulas are small, pure, deterministic expressions over named columns and names. They are parsed and evaluated by the runtime's own interpreter and never passed to eval or Function. The same file MUST produce the same values in every conforming implementation.
Contexts and references
- Row context: computed columns, and view templates inside a
c-each. A bare identifier resolves to a field or computed column of the current row, then to a package name. - Package context: names, and view templates outside any
c-each. A bare identifier resolves to a package name, then to a resource name (a table reference, only valid as an argument toROWS). table.fieldis the whole column as a list, in row order, in either context. In row context of the same table it is still the whole column, soamount / SUM(lines.amount)gives a share of total.- An unresolved identifier is
#NAME. Atable.fieldwhose table or field doesn't exist is#REF.
Grammar
expr = compare ;
compare = concat [ ( "=" | "<>" | "<" | "<=" | ">" | ">=" ) concat ] ;
concat = additive { "&" additive } ;
additive = term { ( "+" | "-" ) term } ;
term = unary { ( "*" | "/" ) unary } ;
unary = ( "-" | "+" ) unary | power ;
power = postfix [ "^" unary ] ;
postfix = primary { "@" ( IDENT | "(" setting { "," setting } ")" ) } ;
setting = IDENT "=" expr | IDENT "[" key "]" "." IDENT "=" expr ;
key = (* a row name, as cello's tools name rows: a key, several key values, column=value pairs, or #n *) ;
primary = number | string | "TRUE" | "FALSE" | "NULL" | call | ref | "(" expr ")" ;
call = name "(" [ expr { "," expr } ] ")" ;
ref = IDENT [ "." IDENT ] ;
IDENT = [a-z] [a-z0-9_]* ;
name = [A-Za-z] [A-Za-z0-9_]* ; (* a name followed by "(" is a call *)
number = digit+ [ "." digit+ ] [ ( "e" | "E" ) [ "+" | "-" ] digit+ ] ;
string = '"' { any char except '"' | '""' } '"' ;
- Whitespace between tokens is ignored. There are no comments.
- Function names and
TRUE,FALSE,NULLare case-insensitive; the canonical form is uppercase. Identifiers are lowercase only. - Comparison is non-associative:
a = b = cis a parse error. -2^2is-4(math convention). This deliberately differs from Excel and OpenFormula, where it is4.
Types
number: IEEE 754 double. Integer fields load as numbers. A NaN or infinite result is#NUM; division by zero is#DIV/0.string: equality and ordering are case-sensitive, by code point. This deliberately differs from Excel.boolean,date(calendar date, no zone),datetime(UTC instant),null,error.list: produced by column references and list functions. The row value of alistfield is a list; its column is a list of lists.- No implicit coercion.
"5" + 1is#VALUE. Comparing different types is#VALUE, except comparisons involving null. date + numberadds days.date - dateis a number of days.datetime - datetimeis fractional days. Mixingdateanddatetimeis#VALUE.
Nulls
- Arithmetic and comparison with null give null.
&andCONCATtreat null as the empty string.- Aggregates skip nulls.
SUMof nothing is0;AVERAGEof nothing is#DIV/0;MINandMAXof nothing are null. IF,AND,OR,NOT, andFILTERtreat a null condition asFALSE, soNOT(NULL)isTRUE.
Errors
Codes: #NAME, #REF, #VALUE, #DIV/0, #NUM, #CYCLE, #LEN. An operator or function that receives an error returns the first one, left to right. IFERROR and ISERROR are the exceptions. An aggregate over a list containing an error returns that error. Rendered errors show the code and set data-error to name, ref, value, div0, num, cycle, or len.
Lists and broadcasting
- A binary operator with a list and a scalar applies elementwise. Two lists apply pairwise if they have the same length; otherwise the result is
#LEN. - Elementwise functions (marked below) map over list arguments the same way.
- Aggregates flatten one level:
SUM(1, lines.amount)works. - A computed column cell or a name MUST evaluate to a scalar. A list result is
#VALUE. Row sets for views come from view queries, not names.
Functions
Functions marked OF follow OpenFormula (ODF 1.4 Part 4) semantics, except for the null and list rules above. Functions marked E are elementwise.
| Function | Notes |
|---|---|
SUM(…), AVERAGE(…) |
OF. Aggregates. |
MIN(…), MAX(…) |
OF. Aggregates over numbers, dates, or datetimes; mixing types is #VALUE. |
COUNT(…) |
OF. Count of numbers (not dates). |
COUNTA(…) |
OF. Count of non-null values. |
ROUND(x, [digits=0]), ROUNDUP, ROUNDDOWN |
OF, E. ROUND is half away from zero, applied to the shortest round-trip decimal of x, so ROUND(1.005, 2) is 1.01. |
ABS(x), MOD(a, b) |
OF, E. MOD takes the sign of the divisor. |
PRODUCT(…) |
OF. Aggregate. With no numbers it is 0. |
EXP(x), LN(x) |
OF, E. LN of zero or less is #NUM; a result too large for a number is #NUM. |
IF(cond, then, [else=NULL]) |
OF. Lazy: only the chosen branch is evaluated. |
AND(…), OR(…), NOT(x) |
OF. |
IFERROR(x, fallback), ISERROR(x), ISBLANK(x) |
OF, E. |
COALESCE(a, b, …) |
E. First non-null argument. |
LEN, UPPER, LOWER, TRIM |
OF, E. |
LEFT(s, n), RIGHT(s, n), MID(s, start, n) |
OF, E. 1-based. |
CONCAT(…) |
OF. Null as empty string. |
CONTAINS(text, part) |
E. Case-sensitive substring test. |
DATE(y, m, d), YEAR, MONTH, DAY |
OF, E. |
EDATE(date, months), EOMONTH(date, months), DAYS(end, start) |
OF, E. |
PERIODEND(date, period), PERIODLABEL(date, period) |
The last day of the year, quarter or month (period is "year", "quarter" or "month") a date falls in, for grouping; and its name: 2026, Q3 2026, Sep 2026. cello only. |
FILTER(list, conditions) |
Keeps elements where the same-length boolean list is TRUE. |
TAKE(list, n) |
First n elements; negative n takes from the end. |
INDEX(list, n) |
OF. The nth element, 1-based; n is truncated. Outside 1 to the list length is #REF; a non-list is #VALUE. |
UNIQUE(list) |
Distinct values, first-occurrence order. |
XLOOKUP(key, keys, values, [if_not_found=NULL]) |
Exact match, first hit. |
HAS(list, item) |
E over a list of lists. TRUE if item is in list. |
ROWS(table) |
Row count. |
ROWNUM() |
1-based index of the current row. #VALUE in package context. |
INPUT(name) |
The value of the input whose name is the text name. #NAME for no such input, or for a name that is worked out. |
There is no TODAY, NOW, RAND, or TEXT. Nondeterministic functions would break reproducibility; use an input name such as as_of. Display formatting belongs to views. Running totals use SUM(TAKE(lines.amount, ROWNUM())). A column can also read its own earlier rows; see Evaluation.
Evaluation
Dependency graph nodes: each name and each computed column (the whole column). Stored columns and input names are leaves. Both branches of
IFcount as dependencies.Cycles are detected with strongly connected components. Every node in a cycle evaluates to
#CYCLEin every cell, except in a row group (below).Row groups. A spreadsheet tracks single cells, so a cell may read the cell above it in its own column; cello tracks whole columns, so it allows the same thing only in a shape it can check without evaluating. A cycle is a row group when all of these hold:
- every node in it is a computed column of the same table;
- every reference from one of its columns to another (or to itself) is either a bare same-row reference,
INDEX(table.column, ROWNUM() - k)withka number literal of at least 1, orTAKE(table.column, ROWNUM() - 1), wheretableis the column's own table; - the same-row references alone have no cycle.
A row group is evaluated row by row in stored order; within a row, its columns are evaluated so that same-row references come first. Every read then sees a finished cell. Any other cycle is
#CYCLE. Guard the first rows withIF, sinceINDEXbefore row 1 is#REF:IF(ROWNUM() = 1, opening, INDEX(accounts.balance, ROWNUM() - 1) + change). PreferINDEXfor running values: eachTAKE(…, ROWNUM() - 1)cell reads every row above it, so its cost grows with the square of the row count.What if:
@.x@wordisxevaluated as if the input whose choices includeword(the case setting, or a dial) were set to it. A word that several inputs offer belongs to the main setting; otherwise it is#NAME, and the input must be named:x@(spending = "lean").x@(a = e1, t[row].c = e2)isxevaluated as if inputaheld the value ofe1and the stored cellcof the named row ofthelde2; eacheis evaluated first, in the current context. The file is not changed.@binds tighter than every operator and chains left to right; where two settings of a chain set the same thing, the one nearestxwins. Settings apply on top of any what-ifs already in force. A name that isn't an input, or a row that doesn't exist, is#REF; an unknown case is#NAME. Implementations SHOULD evaluate each distinct setting lazily, computing only the values asked for, and cache it until the data changes.Evaluate in topological order. Full recompute of 100,000 stored cells plus formulas SHOULD finish in under 200 ms on a 2023 laptop.
Renaming a field, computed column, resource, or name rewrites every formula that references it. The rewrite replaces identifier tokens only and leaves all other characters untouched. Formulas are stored as written; there is no canonical reformatting.
Edge cases
These follow from the rules above; the conformance suite (conformance/formulas/clarifications.json) pins each one.
- Empty text is null everywhere, including results:
NULL & NULL,LEFT("hi", 0), and""are all null.LEN("")is0andISBLANK("")isTRUE. &andCONCATjoin text only.1 & "x"is#VALUE; there is no implicit number-to-text conversion.- Text functions read null as empty text (
LEN(NULL)is0). Number and date functions pass null through (ROUND(NULL),YEAR(NULL),EDATE(NULL, 1)are null).HAS(NULL, x)isFALSE. - Errors win over null:
NULL + foois#NAME. The null rule wins over division:NULL / 0is null. 0 ^ -1is#NUM(infinite result).0 ^ 0is1. A number literal too large for a double (1e400) is#NUM.- Dates and datetimes cover years 0000 through 9999; results outside that range are
#NUM. Years are taken literally (DATE(99, 1, 1)is 0099-01-01), in the proleptic Gregorian calendar. - Dates:
date - numberandnumber + dateare dates; only whole days can be added (as_of + 0.5is#VALUE).date + dateis#VALUE.datetime ± numberadds fractional days.YEAR,MONTH, andDAYread datetimes in UTC.DATErolls over out-of-range parts:DATE(2026, 13, 1)is 2027-01-01. ROUNDUPandROUNDDOWNalso work on the shortest decimal:ROUNDUP(1.1, 1)is1.1.COALESCEreads its arguments left to right and returns the first non-null one, soCOALESCE(1, 1/0)is1andCOALESCE(1/0, 1)is#DIV/0.COUNTandCOUNTAare aggregates, so an error in their input is returned.COUNTcounts numbers only.ISBLANKof an error returns the error; onlyIFERRORandISERRORaccept errors.ROWS(table)works in any context. A table name anywhere else is#VALUE.- A wrong argument count is
#VALUE, andcello checkreports it.SUM()is0. TAKEpast either end returns the whole list.UNIQUEkeeps null once.XLOOKUPwith keys and values of different lengths is#LEN; a key of another type matches nothing.- Aggregates take numbers only (
SUM(TRUE)is#VALUE);MINandMAXalso take dates or datetimes of one kind. - Flattening stops at each row's list:
COUNTA(lines.tags)counts rows with tags, andSUMof a list-of-lists column is#VALUE. - Text length and positions count code points:
LEN("😀")is1. - Unary minus is elementwise. Conditions must be booleans:
IF(1, …)andAND(1, TRUE)are#VALUE.FILTERwith a single condition applies it to every element.
Views
A view is a query, a template, and a stylesheet. The template is plain HTML with five directive attributes and {{ }} interpolation; it cannot run code, and all output is inserted as text.
Definition
"views": [
{ "name": "invoice", "title": "Invoice",
"queries": {
"billable": { "from": "lines", "where": "HAS(tags, \"billable\")", "sort": [["date", "asc"]] }
} }
]
namematches^[a-z][a-z0-9_]*$.gridis reserved for the built-in grid.titleis what the view is called in tabs and links;description, optional, is a line saying what it shows, which a contents page (c-pages) puts under the title.- A view named
indexis the file's index view: interfaces list it first, before the other views and then the tables, and a file withoutcello.defaultViewopens on it. Use it as the front page of a file with several views. - Each custom view has exactly one template block with a matching
data-cello-view. - A query has
from(a resource, required),where(a row-context formula;FALSEor null excludes the row),sort(a list of[formula, "asc" | "desc"], stable, nulls last), andlimit(optional integer). - In a template,
c-eachresolves a query name first, then a resource name (all rows, stored order).
Grouped queries
A query with group returns one result per group of rows instead of one per row, for summaries such as spending per category or per month.
"spend_by_month": { "from": "expenses", "where": "NOT(ISBLANK(category))",
"group": { "month": "EOMONTH(date, 0)" }, "sort": [["SUM(amount)", "desc"]] }
groupmaps key names to row formulas. Rows whose keys are all equal form one group; groups come in the order of their first row, beforesort. A null key forms its own group. A row whose key is an error or a list is left out and reported, like a failingwhere.wherefilters rows before grouping.sortandlimitthen apply to the groups.- Inside a grouped
c-each(and in the query'ssort), a key name is that group's key, and a column of thefromtable is the list of that column's values in the group's rows:{{ SUM(amount) }},{{ COUNT(amount) }},{{ MAX(date) }}. A key named like a column hides the column.ROWNUM()is the group's position.c-ifon the same element filters groups. - A key that is exactly a column (
"category": "category") formats like that column. So does a total of one column,SUM,AVERAGE,MINorMAXof a bare reference or ofFILTER(column, …), anywhere in a template, so money stays money. - Each group element gets
data-tableand onedata-<key>per key with a value (dates in canonical form), so CSS can style groups.c-inputcan change input names from a group, but not the group's columns. package.cello.locale(BCP 47) sets display formatting; defaulten-US. Printed output must not depend on the viewer's machine.
Directives
| Attribute | Behavior |
|---|---|
c-each="<query or resource>" |
Repeats the element once per row. Inside it is row context, and ROWNUM() is the position in the query result. Nested c-each is an error in v0.1. |
c-if="<formula>" |
Renders the element only if the formula is TRUE. On the same element as c-each, it is evaluated per row. |
c-else |
On the element immediately after a c-if element; rendered when that c-if was not. |
c-empty |
On the element immediately after a c-each element; rendered when the iteration has zero rows. |
c-input="<name or column>" |
Lets a person change a value from the view. The value is an input name, or inside c-each a stored column of the row (a stored column wins over a name of the same spelling). Computed columns and formula names are errors. The element must be empty: a viewer that allows changes fills it with a control chosen from the type (a checkbox for booleans, a list for categories, a number box, a date picker, or a text box); one that doesn't, such as cello render, fills it with the value formatted as {{ }} would. Printed, a control loses its frame so the page shows the value. The element gets data-cello-input set to the name or column. See What-if changes. |
Directive attributes are removed from the rendered output. Each rendered c-each element gets the exposure attributes from Semantic fields and tags.
Interpolation and formatting
{{ formula }} or {{ formula | filter }} in text nodes and attribute values. The result is set with textContent or setAttribute, never as HTML. Interpolation is not allowed in on* attributes (which are forbidden anyway), in href or src attributes (literal values only) or inside c-* attributes, which hold bare formulas.
Default formatting, when no filter is given:
| Value | Default display |
|---|---|
Bare reference with a currency unit |
Intl.NumberFormat currency style |
Bare reference with unit: "percent" |
percent style, up to 2 fraction digits |
| Bare reference with another unit | number, a space, the unit |
| Other number | Intl.NumberFormat default |
| Boolean | Yes / No |
| Date | dateStyle: "medium", UTC |
| Datetime | dateStyle: "medium", timeStyle: "short", UTC |
| List | items joined by , |
| Null | empty |
| Error | the code, e.g. #DIV/0 |
Filters: number(digits), currency([code]) (code defaults to the unit), percent(digits), compact (three significant figures with a scale word, $1.72M, for tables that need narrow columns), date(short|medium|long|full), datetime(short|medium|long|full), upper, lower, raw (the canonical CSV text).
Built-in pieces
A template asks for a chart, a summary box, a settings bar or an inputs panel by element, and cello draws it. The file names what to show and never holds drawing code, so a piece is as safe as the rest of the template, draws the same in the runtime, the editor and cello render, prints, and reads as text in cello view. Pieces other than c-fold and c-intro are empty elements written with closing tags, like any other (<c-stat …></c-stat>). They can't sit inside c-each; they take class, id, style, c-if and c-else.
<c-settings names="case growth spending" switch="case" note="Case sets the others together."></c-settings>
<section class="c-stats">
<c-stat label="Lowest cash" value="cash_low" note="{{ cash_low_month | date(medium) }}" spark="TAKE(months.close, 36)"></c-stat>
</section>
<c-chart from="months" x="month">
<c-bars value="revenue"></c-bars>
<c-bars value="spending"></c-bars>
<c-line value="cash" scale="right"></c-line>
<c-line value="cash@low" scale="right"></c-line>
</c-chart>
<c-inputs></c-inputs>
| Element | Attributes | Draws |
|---|---|---|
c-chart |
from (a query of the view or a table, as c-each), x (a row formula), title, stack |
Bars, areas and lines over the rows, from its c-bars, c-area and c-line children. Over a grouped query there is one point per group, and a column is the group's list of values (SUM(FILTER(amount, category = "rent"))). With stack, bars sit on one another, as do areas. A c-bars or c-area with its own stack="name" piles only with others of that name, and each stack stands beside the rest: revenue stacked by product beside spending as its own bar. |
c-area |
value, label, scale, stack |
A series filled down to zero, or to the area below it when stacked. |
c-pie |
from, label and value (row formulas), donut, center (text in a doughnut's middle; default the total), title |
A pie, or with donut a ring, one slice per row or group, with a legend of each value and its share. |
c-hbars |
from, label, value, title |
Bars across, one per row or group in the query's order: a ranking that also reads as a table. |
c-bars, c-line |
value (a row formula), label, scale (left, the default, or right), stack on c-bars (see c-chart); c-line also look (solid or dotted) |
One series. Without label, the series is named by its column's title, or by the case for col@case. Units come from the column, so money is money. |
c-stat |
label (required), value (a formula, required), note, spark (a formula giving a list), meter (a formula giving 0 to 1), tone (a formula giving good, warn or bad) |
A summary box: the label on one line, the value (money in whole units), a note line kept even when empty, and a small trend line or meter. Boxes inside an element with class c-stats line up in a grid. |
c-settings |
names (input names, separated by spaces or commas; required), switch (those of them drawn as buttons side by side), note |
Inputs as one bar. An input's title is split into a short label and help at a colon or parenthesis (Growth: how the market responds), but not at a colon followed by only a word or two (Work: On stays whole); the help shows in a line under the bar while the input is hovered or focused, and note the rest of the time. |
c-period |
input (required: an input whose choices are periods, such as year, quarter and month), label |
Buttons for showing the view by each choice. The view is drawn as if the input held the choice made, for the person looking only: never saved, never a what-if. Group a query with PERIODEND(date, input) and name each group with PERIODLABEL. Printed, only the choice shown remains. |
c-link |
view, table or at (one of them, required) |
A link to another view or table of the file, or with at to a place in it (group:Series A, input:price, heading:pnl/By month, cell:expenses[rent].amount; see "Deep links"), around its content, or, empty, the view's, table's or place's name. A page that opens it itself (the editor, cello.sh) does; elsewhere it is an ordinary link to #view=… or #at=…, which the runtime follows. |
c-why |
of (a formula; optional) |
A small (i) where it stands, which opens a note on hover or click (the browser's popover, so it opens without a script too). The note holds the element's content (the author's words, which may hold c-link), then, with of, how that value is worked out: its title and value, its formula with each name shown by its title as a link to it (#at=input:… for an input of the inputs table, else #at=name:…), and the inputs it rests on, followed through names and calculated columns. Needs of, content, or both. Not printed. |
c-pages |
views (names, in order; default every view but this one), tables (names; default none) |
A contents page: a card for each, with its title and the view's description (a table's says how many rows), each a link as c-link. For a cover page. |
c-fold |
title (required), note (shown at the right of the title), open |
A section that folds away, styled like a group of the inputs panel, around any template content (tables, c-each, other pieces). |
c-leverage |
value (a name or formula, required), top (rows shown; default 10), labels (only inputs with one of these), title |
What moves a result: each input it reads is set to the lowest and the highest of its values across the cases, one at a time with the others as they are, and the inputs are listed by how far the result swings, widest first, each a bar between the two results about today's value. Inputs held by an override or pick, or the same in every case, aren't tried. A big file can take minutes, so a live page draws the piece with a button and works its rows out only when the button is clicked, filling them in as they come; after an edit it keeps the last answer, marked out of date, with a button to work it out again. Print, render and text work the rows out before drawing; an exported file's drawn preview leaves them out and says so. |
c-intro |
group (required), inside c-inputs |
Template content shown at the top of that group, above its rows. |
c-inputs |
table (default: every inputs table, a linked model's merged into this file's groups), group-by (default group), note (default the first of why, note, notes, source, description), open (the group shown open; default the first), order (group names separated by ` |
`, placed first in that order; the rest follow as found) |
- Scales. Bars and lines on the left scale share zero and gridlines with the right scale. A scale stops at 1.6 times its solid series, so another case far above the chosen one runs off the top with its value and an arrow instead of flattening it. Bars start at zero, so at least half the height stays above zero.
- Other cases. A
c-linewhose formula uses@is drawn dim and dotted unlesslooksays otherwise. One that comes out the same as a solid line (the case already in force) isn't drawn. - Below zero. A solid line below zero is red there, with a red wash down to zero, and the legend adds "below zero".
- Lines are straight between rows, so a step in the data shows in the row it happens.
- Labels. Gridlines use round steps and compact numbers (
$1.2M). Each line is labelled at its last row. The legend is split into left and right scales when both are used. Dates on the first of each month label January of each year (or every third month for a year and a half or less). - Text form. A chart also writes its numbers as a table, hidden on screen, for screen readers and
cello view; the drawing itself is skipped there. - Errors. A value that isn't a number is left out of the chart and reported as a warning. Unknown attributes, missing required ones, a series outside a chart, a piece inside
c-each, and names that aren't inputs are errors. - In a browser, a chart redraws at its real width, rises in the first time it shows, moves from its old numbers to its new ones when a what-if changes them, and shows a card with every series' value for the month under the pointer. Motion stops when the reader asks for less. Groups of an inputs panel stay folded or open across redraws, and the dot on each range is a slider: dragging it or using the arrow keys sets the row's
override, in steps of about a sixtieth of the range, as a what-if. - Styling. Pieces draw in the text color around them, so they suit light and dark views. A view can set
--c-1to--c-6(series colors),--c-good,--c-warn,--c-bad, and--c-bg(the panel color, also used behind labels). The classc-tablegives a table single-line headers and cells, with group headings forthelements that span columns. cello renamerewrites names, columns and tables in pieces' attributes as it does in other formulas.
Allowed HTML
Core parses template text with its own strict HTML parser, the same in the runtime and the CLI, so both build the same tree from the same text (a browser parser would silently move stray text out of tables). Every non-void element needs an explicit closing tag; the void elements are br, hr, img, col. Character references are decoded. The parsed template is validated before rendering. Anything outside the allowlist is a validation error, and the view shows the error instead of rendering.
- Elements:
div span p h1–h6 section header footer main article aside nav table caption colgroup col thead tbody tfoot tr th td ul ol li dl dt dd strong em b i u small sub sup br hr figure figcaption blockquote address time img a - Built-in pieces:
c-chart c-bars c-line c-area c-pie c-hbars c-stat c-leverage c-settings c-inputs c-intro c-fold(see Built-in pieces) - Attributes:
class id title lang dir style role aria-* colspan rowspan scope headers datetime alt width height,data-*except reserved names,srconimg(data:URIs only),hrefona(https:,http:,mailto:,#only) - Never allowed:
script,styleelements inside templates,iframe,object,embed,form,input,link,meta,base,svg,math, anyon*attribute
Styles and printing
- The runtime enables only the active view's
<style>blocks, plus*blocks for custom views, by togglingsheet.disabled. No scoping is needed. - Styles with
data-cello-view="grid"apply to the built-in grid, so tag styling like highlighted rows works there too. - The active view renders into
<main data-cello-view="<name>">. - Printing prints the active view only. Runtime chrome is hidden with
@media print. View CSS uses paged media:@page { size: letter; margin: 0.75in },break-before,break-inside. - The URL fragment selects the view:
#view=invoice, or#view=grid&table=lines.
Template details
The rules above leave some cases open; the runtime and CLI settle them the same way.
- Character references are decoded everywhere, including inside
{{ }}. Inside{{ }},<is literal, so{{ a < b }}works. A formula with string literals inside a double-quoted attribute needs single quotes around the attribute or". - A
<not followed by a letter,/, or!is literal text. Self-closing syntax on a non-void element (<div/>) and closing a void element (</br>) are errors, as are duplicate attributes. - One filter per interpolation. Filter arguments may be bare or quoted:
currency(EUR)orcurrency("EUR").currencywith no code is an error unless the value is a bare reference with a currency unit. A filter that doesn't fit the value's type falls back to the default display, and filters apply to each item of a list. number(n)andpercent(n)fix exactlyndecimals; withoutn, numbers useIntldefaults and percents show up to 2.dateon a datetime shows the date part only.c-elsecan't sit on an element that also hasc-if,c-each, orc-empty(there is no else-if).c-emptycan't be combined withc-eachorc-if, and it shows when zero rows were actually rendered, after any per-rowc-if.- A
c-iforwherethat evaluates to an error or a non-boolean leaves the element or row out and reports a warning. - Sorting puts nulls last in both directions, with errors and lists just before them. Mixed types group in the order number, date, datetime, string, boolean (reversed for
desc). Sorts are stable. - Row attributes are written in the order
data-table,data-row, stored fields in schema order, computed columns, thendata-invalidanddata-error. A computed column is exposed when its declaredtypeisboolean, or when it has no declared type and evaluates to a boolean. "Invalid" covers parse failures, constraint failures other thanunique, and rows with the wrong number of cells. Exposure attributes overwrite a template's owndata-*of the same name. hrefmust start withhttps:,http:,mailto:, or#(so relative links are rejected) andimg srcwithdata:. Interpolation is allowed instyleanddata-*attributes.- Inside a
c-each, a bare reference takes the unit of the column it names;table.fieldtakes that column's unit and formats each item.
Template example
<header><h1>Invoice for {{ client }}</h1><p>Due {{ due_date | date(long) }}</p></header>
<table>
<thead><tr><th>Item</th><th>Qty</th><th>Amount</th></tr></thead>
<tbody>
<tr c-each="billable"><td>{{ item }}</td><td>{{ qty }}</td><td>{{ line_total }}</td></tr>
<tr c-empty><td colspan="3">No billable lines.</td></tr>
</tbody>
<tfoot><tr><td colspan="2">Total</td><td>{{ total }}</td></tr></tfoot>
</table>
Runtime
The runtime is one dependency-free script at the end of the file. It boots from the blocks and shows the data: a read-only grid and the views. It never writes the file; changes made through c-input controls are what-ifs (below). People and agents change the file as text and check it with the CLI (see agent editing contract); an editing app is a separate program.
Boot sequence
- Read and parse
#cello-package. Checkcello.version. - Read each CSV block by
data-cello-path. - Parse CSV into typed columns per schema. Flag invalid values.
- Parse all formulas, build the dependency graph, evaluate.
- Parse and validate templates. Collect style blocks.
- Build the chrome: title, view switcher, table tabs, names panel, print, diagnostics count, runtime version and hash.
- Pick the view from the URL fragment or
cello.defaultViewand render it.
A failure at any step shows a diagnostics panel (block, line, message), never a blank page. If the descriptor doesn't parse, the panel shows the raw blocks read-only.
What-if changes
A change made through a c-input control is a what-if: the viewer applies it to its own copy of the data, recalculates, and redraws every view and the grid, but the file stays as it was. While any what-if is held, a bar across the top says how many there are, with Undo (the last change), Reset (all of them) and Save. The bar is chrome, so it never prints.
- The count in the bar opens a list of the changes, oldest first, each in the words the view uses ("Months: 3 → 6"; a row is named by its
label,titleornamecolumn when it has one). - Anything the view shows differently from the saved file, a number a change moved or a control's own value, is marked
data-cello-changedwith the saved text indata-cello-was(and as a tooltip when the element has notitle), so the effect of a change shows where it lands. Printing drops the marks. - Save writes the what-ifs into the file as ordinary edits, in canonical form. Only a viewer that can write the file offers it: the editor's view windows do (see the editor spec); the runtime inside the file itself can't, so its Save is disabled and says to open the file with
cello edit. - A value that doesn't fit its target is refused and nothing changes: text in a number, a fraction in an integer, a value outside
categoriesor an input'sminandmax, or one that breaks a column's constraints. - A control whose unit is
percentshows and takes the value as a percent:8.75for 0.0875. Text written by tools (edit scripts,--set, formulas) always uses the stored fraction. - A change to an input kept in an inputs table changes the cell that decides it now, as saving would: the column of the case in force (or the picked case, or
value), so the input's other cases keep their values. It is refused when anoverrideor aderiveformula decides it. An input set inside a formula with@(name = …)holds in every case. A stored value already outsidecategoriesstill shows in the list, so a control never hides what the file holds. - When the file changes underneath (an agent's edit), the viewer replays the what-ifs on the new text. One that no longer applies is dropped and the bar says so: for a column, that means any change to the row it was made on, including rows moving; for a name, a change to the name. Nothing is ever forced over someone else's edit.
- Changes made while a save is in flight stay as what-ifs on top of what was saved.
Grid view
- One tab per table. Headers show
title, type, and unit; hovering shows the fieldname. Computed columns sit after stored columns, visibly distinct. - Values use the default display formatting from Views; in the inputs table, each row's own unit. Invalid values show their raw text with
data-invalidand a tooltip naming the failed constraint or parse error. - Row elements carry the exposure attributes from Semantic fields and tags, so
gridstyles apply. - The names panel lists every name with its title, formula (if any), and current value.
- Keyboard: arrows move a focus cell; Cmd/Ctrl-C copies the focused cell, or a Shift-selected range as TSV. A copy menu puts the current table on the clipboard as CSV or TSV.
- Grids above 1,000 rows SHOULD render only visible rows.
- Accessibility:
role="grid", full keyboard navigation, visible focus.
Seeing changes
A page opened from file:// can't watch its own file, and the CSP blocks any connection that could tell it about a change. Reloading the page shows the current file. cello watch (CLI) gives live updates without loosening the file's CSP.
The chrome uses system fonts, follows prefers-color-scheme, sits under [data-cello-chrome], and is hidden when printing.
Security model
A cello file is HTML, so opening one runs code. The design limits that code to one known runtime, gives it no network access, and treats everything people and agents edit as inert data.
Content Security Policy
Every file carries exactly this policy, with the runtime's hash filled in:
default-src 'none'; script-src 'sha256-<base64 of runtime textContent>'; style-src 'unsafe-inline'; img-src data:; font-src data:; base-uri 'none'; form-action 'none'
- Only the runtime runs. A
<script>smuggled in through data or a template has the wrong hash and is blocked. Inline event handlers andjavascript:URLs are blocked too. connect-src,frame-src,worker-src, andobject-srcfall back to'none': no fetch, XHR, WebSocket, frames, workers, or plugins.- CSS is allowed inline but can only load
data:images and fonts, so CSS-selector exfiltration (attribute selectors plusurl()) has nowhere to send data. - The policy goes in a
<meta>tag because the file has no server. It MUST come before every script.
Template and formula restrictions
- Templates are validated against the allowlist in Views before rendering, and output is only ever set as text.
- Interpolation is not allowed in
hreforsrc. Link and image targets are literal, so a template can't build a URL containing data that leaks when someone clicks it. - Formulas run in the runtime's own interpreter. The language has no property access, no string-to-code path, and no access to JavaScript globals.
- Parser limits: formulas up to 4 KB, AST depth up to 256. The evaluator SHOULD enforce an operation budget per recompute; when exceeded it stops, shows a diagnostic, and affected cells show
#NUM.
Untrusted files
CSP protects a file whose runtime you trust from injected content. It does not protect you from a file whose author wrote a malicious runtime and put its hash in the CSP.
- The CLI ships a manifest of official runtime hashes.
cello verifyandcello checkfail on any runtime not in it. cello upgradereplaces the runtime with the official one and rewrites the CSP. Run it, orcello verify, on files from other people before opening them.cello renderproduces static HTML of a view without executing the file's runtime.- The chrome shows the runtime version and hash.
Other rules
- CSV import treats input purely as data and rejects forbidden raw-text sequences.
- No telemetry, no update checks, no network use of any kind.
Agent editing contract
An agent edits a cello file as text, with no browser, then checks its work with the CLI. The rules below are what make that safe, and the repo ships them as GUIDE.md (also read as AGENTS.md, where coding agents look) and an agent skill.
What may be edited
| Block | Agent may edit |
|---|---|
#cello-package descriptor |
yes |
| CSV blocks | yes |
| template blocks | yes |
view <style> blocks |
yes |
CSP <meta>, noscript, runtime |
never |
Rules
- Adding, removing, or renaming a column changes the CSV header and the schema
fieldstogether. To rename, usecello rename, which also updates every formula and template that references it. - Derived numbers are formulas (computed columns or names), never values typed into CSV.
- Meaning goes in data (categories, tags, computed booleans), never only in a template or stylesheet.
- Keep CSV canonical (
cello fmtdoes this) and keep row order unless asked to change it. - Never write a forbidden raw-text sequence (
</script,<script,<!--,</style). - After editing, run
cello check <file>, andcello eval <file> <formula>for any value you claim. - When editing someone else's file, run
cello check --against <original>. It fails if anything outside the editable blocks changed. - Linked tables and values (they carry a
link) are copies from another file: change them at their source and runcello refresh, never by editing the copy.
Token economy
Editable blocks come first in the file and the runtime comes last, so an agent can read up to <script data-cello-runtime and stop. For chat, cello extract prints only the editable blocks, and cello apply puts an edited extract back into the file. A large file is read a piece at a time instead: cello outline first (views, tables, inputs and results, a thousand or two tokens), then one view with cello view, then only the names, columns or rows needed (names --match, columns --match, rows --where), and single numbers with eval and explain; --set answers a what-if without writing. The agent guide shows the order.
Column-name formulas also remove the spreadsheet error agents make most, the header-row off-by-one, because there are no row numbers to get wrong.
CLI
cello is a Node 20+ command with no runtime dependencies, built on the same core library as the browser runtime. It is how agents validate and inspect files without a browser.
| Command | What it does |
|---|---|
cello guide [<topic>] |
Prints the agent editing contract and a formula and view reference (the repo's GUIDE.md, embedded at build time). A topic (inputs, views, helpers, …) prints just that part. |
cello --version |
Prints the bundled runtime's version, and when and from which commit the command was built. |
cello new <file> [--title <t>] |
Creates a file with the official runtime and one empty table, items, with a name string field. --example invoice or --example budget starts from a complete example instead. |
cello check <file> [--against <orig>] [--json] [--strict] [--links] |
Validates everything: block set and order, descriptor, CSV conformance and canonical form, constraints, formula parsing, name resolution, cycles, template allowlist, forbidden sequences, runtime hash in the manifest, CSP hash matching the runtime. --against also fails if anything outside the editable blocks differs from <orig>. --links also warns when a linked copy is behind its source. |
cello outline <file> |
Prints a short outline for agents: the number of open comments, views, each table's row count, key and column names (calculated ones marked), inputs by group with the case in force, inputs kept in hand-built tables with the row to change, results with formatted values, links, and a problem count. No formulas or rows. |
cello view <file> <view> [--section <heading>] [--max-tokens <n>] [--from <line>] [--full] |
Prints one view as text: headings and paragraphs, markdown tables (a cell spanning columns keeps the rest in line), numbers formatted from their units. A long chart is given as a sample of its rows, and what is slow to work out (leverage) or meant for clicking is left out, saying so in place; --full gives everything. --section gives the part under one heading; --max-tokens and --from read a long view in pieces. |
cello explain <file> <name, table.column or formula> [--row <n>] [--depth <n>] |
Prints how a value comes about: its formula, the values it reads (whole columns as a count with their total for money, else their range), and the names it uses, followed to --depth (default 3) down to the inputs; then the names its calculated columns read. A bare column name that belongs to one table means that table's column. |
--set <name>=<value>, --set <name>@<case>=<value>, --set <table>.<column>[<row>]=<value> |
On eval, view, explain and outline: a what-if. The loaded copy is changed (an input by its declared type, or a stored cell found by row number or key) and the answer worked out from it; the file is never written. eval prints what the value was on stderr. |
cello columns <file> <table> [--match <a|b>] [--columns a,b] |
Prints one table's columns: stored ones with type, unit and allowed values, calculated ones with their formula. --match keeps the columns whose name, title or formula holds a word. |
cello eval <file> [--table <t> --row <n>] [--json] [--] <formula> |
Evaluates a formula in package context, or row context with --table and --row (1-based), and prints the canonical value (lists as [a, b, NULL]; --json prints typed JSON). Exits 1 when the value is or contains an error. Put -- before a formula that starts with -. |
cello push <file> [<model>…] [--dry] [--as <name>] |
Sends the input values this file changed for a linked model (case columns, value, override, pick) back to its source, as one change in the source's log, then refreshes the model here. A value the source has changed since the last copy is not sent, and is listed. Other columns changed here (title, group, notes) stay here. Local sources only. |
cello leverage <file> <name or formula> [--top <n>] [--set …] |
Ranks the inputs a result reads by how far it swings as each moves across its own range, as c-leverage does, with each input's range and the result at both ends. |
cello comments <file> [--take <id,…|all> --as <name>] |
Lists the comments a person left in the editor that no agent has taken yet, oldest first, with what each was left on and what it showed. --take closes them by adding a line to the change log. cello outline starts by saying how many are open. |
cello fmt <file> [--check] |
Rewrites the file in canonical form. --check exits non-zero if anything would change. Like every command that writes, it refuses a file whose blocks don't line up (a CSV row of the wrong width, a header that doesn't match the schema, a block with no matching resource or view), because rewriting it would lose content. |
cello mcp [--as <name>] |
Serves agents over the Model Context Protocol on stdin and stdout: read, check, evaluate, change, and read the change log of any .cello file named in a call. Changes are logged to <file>.log (see cello editor spec). The tools are cello_open close outline view template columns names rows eval explain leverage check guide comments do edit extract apply lease changes history undo refresh push. |
cello export <file> <out.html> |
Writes the file under an .html name, so any browser opens it, with a drawn copy of its front view for viewers that block its script (see No-JS fallback). |
cello export <file> <out.xlsx> |
Writes an Excel workbook: one sheet per table, headed by column titles, with dates, money and percents formatted from their types and units, plus a Names sheet. Calculated columns and names become live Excel formulas where they translate, each with cello's value already in place: a row's column becomes its cell, table.column its range, and a name its cell (or an Excel name). SUM(FILTER(…))-style totals, XLOOKUP, HAS on tags, DAYS and CONCAT become formulas every Excel version runs; UNIQUE, TAKE and other uses of FILTER need Excel 2021 or Microsoft 365. Anything else (COALESCE, for one) is written as values, with a warning. Once in Excel, formulas follow Excel's rules, so text comparisons there ignore case. |
cello export <file> <dir> [--materialize] [--compat] |
Writes datapackage.json, one CSV per table, views/<name>.html plus .css, and views/_grid.css and views/_shared.css for grid and * styles. --materialize adds computed columns to the CSVs and schemas. --compat writes list columns as string fields, moving itemType and delimiter under field.cello.list, for tools that predate the list type (below). |
cello import <datapackage.json, CSVs…, .xlsx files…, or Google Sheets links…> -o <file> |
Builds a cello file from a Data Package or CSV files. For CSV, header cells become identifiers (lowercase, non-alphanumerics to _, a leading digit gets a c_ prefix, duplicates get _2, _3) with the original header as title, and each column is typed integer, number, boolean, or date if every non-empty value parses, otherwise string. Numbers with leading zeros (01234) or more than 15 significant digits stay strings, because canonical writing would change them. Input is treated purely as data; forbidden raw-text sequences are rejected. Each visible sheet of an Excel file (.xlsx) becomes a table, from the values Excel last calculated (formulas aren't carried over); older .xls files and Numbers files need saving as .xlsx first. A Google Sheets link (https://docs.google.com/spreadsheets/d/…, with #gid= picking the tab) is downloaded as CSV; the sheet must be shared as "Anyone with the link" unless you've signed in with cello google login, which also reads private sheets and Excel or CSV files in Drive. A grid from another spreadsheet is tidied first: blank rows and columns are dropped, and a column whose cells all show money in one currency ($1,234.50, ($3.00)), percents (12.5%), thousands separators, or slash dates (month first unless a first part is over 12) is read as numbers with a USD/EUR/GBP/JPY or percent unit, or as dates. |
cello rename <file> <old> <new> [--table <t>] |
Renames a name, resource, field, or computed column (--table for fields), updating the CSV header, the schema, and every formula and template reference, and records the rename in <file>.log so files linking to this one follow it. |
cello link <file> <source> --value <formula> --as <name> |
Allows the source for this file and adds a linked value (see Links to other files). --table <t> instead adds a linked table, with optional --where <formula>, --group <key>=<formula>, --column <name>=<formula>, --sort "<formula> desc" and --limit <n> (the flags that name things may repeat). --pinned waits for cello refresh; --tell records the link in the source's .links list. |
cello refresh <file> [<name>…] [--check] [--allow] |
Brings linked values and tables up to date and says what changed, logging each update. Sources not yet allowed for this file are skipped with a message; --allow allows them first (check they're files you expect). --check changes nothing and exits 1 if any is behind or unreadable. cello check --links also warns about stale links and unreadable sources; a file keeps working from its last copy. |
cello share <files…> [--port <n>] |
Serves the files read-only on this machine's Tailscale address (default port 4747), exactly as they are on disk, so a view's link is the file's address plus #view=<name>. The index page lists each file and its views. Answers only this machine's own names, and sends an ETag so linking files can check for changes cheaply. |
cello edit <file> [--port <n>] [--no-open] |
Opens the file in the editor, a local page in the browser, served by a helper on 127.0.0.1 behind a random token (see cello editor spec). |
cello watch <file> |
Serves a local preview page that shows the file in a frame and reloads it whenever the file changes on disk. The file itself is served unmodified, CSP included. |
cello render <file> --view <name> -o <out.html> |
Writes static HTML for one view: values computed, CSS inlined, no script at all. For email, publishing, or printing to PDF. |
cello extract <file> |
Prints only the editable blocks, as they appear in the file. |
cello apply <file> <extract> [--as <agent>] |
Splices edited blocks from an extract back in, then runs check. A table extract (from extract --table) instead swaps just its tables, as one logged, undoable step, and is refused if one of them changed since the extract was made (its cello.extracted holds each table's fingerprint), if it renames, adds or drops a table, or if a table is a linked copy. |
cello extract <file> --table <t>[,<t>…] [--to <helper>] [--columns a,b] [--where <formula>] |
Prints just those tables: a descriptor holding only their settings (plus cello.extracted), and their data blocks, for one helper agent to edit. --to also leases the tables to that helper. --columns and --where give part of one table, each row with its #, and applying it back changes just those cells and formulas. |
cello do <file> [<edits>] [--dry] [--force] [--lease <token>] [--as <agent>] |
Makes changes given on stdin (or in a file) as one logged step, all or nothing, and prints which named values moved. The input is an edit script (below) or a JSON list of agent edits as cello_edit takes. Refused, changing nothing, if it would add errors (unless --force) or change nothing. |
cello undo <file> [--last <n>] [--by <who>] [--since <#n or time>] [--dry] [--as <agent>] |
Takes back logged changes, newest first, as one new logged step; refused whole if one can't be taken back because the file moved on. |
cello link <file> <source> --model --as <prefix> --results <name|table.column>,... |
Links the source as a model (see Sharing a model). |
cello shared <file> [--inputs <name>,...] [--tables <t>,...] [--preview <name|table.column>,...] |
Sets what the file shares for model links; with no options, shows it. --preview says what linking those results would take. |
cello unlink <file> <prefix> |
Ends a model link; what it brought stays as the file's own. |
cello relink <file> <link> <source> [--was <source>] [--dry] |
Points a linked value or table (by its name) or a linked model (by its prefix) at another source, after checking the new source offers what the link needs; the same as the edit script's relink. |
cello inputs retype <file> <name> boolean [--dry] |
Turns an input kept as 1 or 0 into a yes/no input: sets its row's type, writes down any case value a formula worked out, and rewrites every formula and view that reads it (a comparison with a number becomes the input, its opposite, or a constant; elsewhere it reads IF(x, 1, 0)). Saved only when every other name, computed column and view is unchanged under every case and dial. |
cello inputs adopt <file> [--table <t>] [--cases <json>] [--dial-column <c>] [--dry] [--as <agent>] |
Turns a table of inputs that names look up with XLOOKUP, with a formula that picks each row's value by a case setting, into the inputs table: rows gain names, the lookup names go, the case formula becomes cases, and the looked-up column becomes INPUT(name). Saved as one logged step only when every name, computed column and view evaluates the same under every case, and each row answers an override and each allowed pick the same way; otherwise refused with the differences. |
cello names <file> [--match <word>], cello rows <file> <table> [--columns …] [--where …] [--from <n>] [--count <n>] |
All names with values (inputs, inputs kept in table rows, results); rows as compact CSV numbered #n. |
cello lease <file> [--table … --to <helper> [--hours n] or --release …] |
Grants a helper agent some tables (a token), lists leases, or ends one. While a lease lasts, agent edits to its tables need the token, are held to them, and are logged under the helper's name. Kept in <file>.leases; people editing aren't bound by it. extract --table … --to <helper> grants one with the extract. |
cello changes <file> [--since <#n or time>] |
Lists the change-log entries after --since, then which named values moved, found by undoing those steps on a copy (not possible when the file was also changed outside cello's tools), then the time to ask from next time. |
cello verify <file> |
Checks the runtime hash against the official manifest and the CSP against the runtime. |
cello upgrade <file> |
Replaces the runtime with the bundled official version and updates the CSP and generator tag. |
cello update [<origin>] |
Replaces a downloaded cello tool with the one cello.sh (or origin) serves, after checking it against the SHA-256 served beside it. A tool run from a source checkout is left alone. |
cello google setup | login | logout | status | list |
Signs in to Google (optionally with your own Cloud client), so import reads private Google Sheets and spreadsheet files in Drive; list finds them. |
cello hosted link <origin> [<code>], cello hosted whoami | unlink |
Links this computer to a cello.sh account, so the desktop app and the command can open and save sheets there. |
cello close <address> |
Ends an agent session on a cello.sh sheet (see below). |
Sheets on cello.sh. Wherever a command takes a file, outline, names, view, columns, rows, explain, eval, check, changes, do, undo, refresh, push, relink and unlink also take a sheet's agent address from cello.sh (https://cello.sh/@space/folder/sheet?agent=…#k=…). The part after # is the sheet's key and never leaves the machine: the sheet is unlocked there, and each change is saved back to cello.sh locked. The agent guide covers how sessions start and end. refresh, push, relink and link read other sheets only when the address also opens them; a link naming a sheet by an old name finds it through the space's record of old names.
cello import of an exported package also picks up views/<name>.html and .css, so export then import round-trips a file's data and views.
List columns and other tools. Table Schema v2 defines the list type, but some Data Package tools don't accept it yet. The default export stays standard; --compat is for those tools.
Exit codes: 0 clean, 1 errors, 2 warnings only (with --strict). --json output is a list of diagnostics: { level, code, block, line, column, message }. cello render output uses the policy default-src 'none'; style-src 'unsafe-inline'; img-src data:; font-src data:.
Edit script
One change per line; blank lines and # comments are skipped. Each line compiles to an agent edit, so a script applies exactly as the same edits sent as JSON would.
set NAME[@CASE] = VALUE [was VALUE] an input's value (in one case), read as its declared type
set NAME[@CASE] := FORMULA the same, as the formula's answer, worked out once
set TABLE[ROW].COLUMN = VALUE [was VALUE] a stored cell
set TABLE[ROW].COLUMN := FORMULA the same, worked out in that row
add TABLE COLUMN = VALUE, COLUMN = VALUE, … a new row; unnamed columns are empty
update TABLE set COLUMN = VALUE, COLUMN := FORMULA, … [where FORMULA]
delete TABLE[ROW]
delete TABLE where FORMULA
calc TABLE.COLUMN := FORMULA [; unit U] [; title "T"] [; type T]
name NAME := FORMULA [; unit U] [; title "T"]
rename [TABLE.]OLD to NEW
relink LINK to PATH [was PATH] a link's source; LINK is a linked table or value's name, or a model's prefix
when KEY := FORMULA | when KEY always when a group of inputs, or one input by its name, applies (KEY in double quotes if it has spaces)
=stores the value written and:=works out a formula; nothing else assigns.wasrefuses the change if the value is no longer the one given.- A VALUE is a word without spaces or commas, or a JSON-quoted string. It is read as the column's or input's type, as a CSV cell is, so dates are written
2026-10-01. - A FORMULA is the formula language, where a date is
DATE(2026, 10, 1); an unquoted2026-10-01in awhereis refused, since it would be subtraction. - ROW names one row: a key value (the primary key, or a first column whose values are unique), several key values in key order,
column=valuepairs, or#nfor a position. A name matching no row, or several, is refused with the rows it could mean. - Agent saves (script, JSON edits, table hand-backs, renames) that would add errors to the file or change nothing are refused unless forced. Each log entry records every name's value after the change, which
changescompares.
Implementation
One isomorphic TypeScript core does all parsing, evaluation, rendering, and serialization. The browser runtime and the CLI are thin shells around it, so they can't disagree.
+------------------------------+
| @cello/core |
| csv schema formula |
| template document format |
+-------+--------------+-------+
| |
bundled | | imported
(IIFE) v v
+----------------+ +----------------+
| runtime.js | | cello CLI |
| boot grid | | check eval |
| views chrome | | render fmt |
+-------+--------+ +--------+-------+
| sha256 | ships
v v
+------------------------------------+
| manifest.json (official hashes) |
+------------------------------------+
Repo layout
cello/
packages/core/ csv, schema, formula (lexer, parser, evaluator, functions),
template (parse, validate, render), document (file parse and
serialize), format (Intl display)
packages/runtime/ boot, grid, views, chrome
packages/cli/ commands; embeds the runtime build and manifest
packages/editor/ the editor (`cello edit` and the desktop app's window)
packages/desktop/ the desktop app
packages/hosted/ the cello.sh client: encryption, its API, saving to a sheet
hosted/ cello.sh itself, under its own license
conformance/ formulas/, csv/, files/valid/, files/invalid/, profiles/
examples/ invoice.cello, budget.cello
site/ the front page and its examples; /spec and /guide are made from SPEC.md and GUIDE.md
scripts/ builds
SPEC.md this document
GUIDE.md the agent guide (AGENTS.md points to it)
skills/cello/SKILL.md
- TypeScript in strict mode. Zero runtime dependencies. Dev dependencies:
typescript,esbuild,vitest,fast-check,playwright,marked(for the site's pages),@types/node,@tauri-apps/cli. coreMUST NOT touch the DOM or Node APIs directly. Template rendering targets a minimal DOM interface, implemented by the browser DOM in the runtime and by a small string-building adapter in the CLI.
Build
- Bundle core and runtime into one minified IIFE, ES2022 target. Budget: 190 KB minified.
- Fail the build if the bundle contains
</script,<script, or<!--(case-insensitive). Source strings that need them use escapes like"<\/script". - Compute the SHA-256 of the exact bytes that become the runtime block's text and base64-encode it. A release build appends
{ version, sha256 }tomanifest.json, which keeps every official version. Development builds never touch it;checkandverifyaccept the current development build only with--dev. - The CLI embeds the runtime bundle, the manifest, and the canonical shell used by
new,import, andupgrade.
Tests
- Unit tests per core module.
- Conformance suite, which is part of the spec:
formulas/*.jsoncases of{ context, formula, expected }with canonical values or error codes; CSV round-trip cases; valid files, and invalid files with their expected diagnostic codes. - Property tests with
fast-check: random typed tables survive serialize then parse unchanged, and canonical input serializes byte-identically. - Browser tests in Chromium, Firefox, and WebKit, opening examples from
file://: zero CSP violations, zero network requests (asserted by request interception), view switching, and print-emulation screenshots of the invoice view. - Security tests: a
<script>planted in a template or CSV block (bypassing the writer) does not run;on*attributes and interpolatedhrefare rejected; a CSSurl()produces no request; fuzzed formulas never reach JavaScript globals. - Performance: a 100,000-cell recompute under 200 ms in Chromium in CI.
Acceptance checks
What an implementation must pass, grouped by part. Each runs in CI.
Core data
CSV reader and writer, typed parsing, descriptor validation, file parse and serialize.
- CSV conformance cases pass; canonical input round-trips byte-identically
- Property tests: serialize then parse returns an equal document
- File parser extracts every block type, rejects forbidden sequences, and reports unknown elements
Formulas
Lexer, parser, evaluator, function catalog, dependency graph, cycle detection, rename rewriting.
- Formula conformance suite passes, with at least 300 cases covering every function, null rule, and error rule
-2^2is-4,ROUND(1.005, 2)is1.01, and a two-node cycle yields#CYCLEin both- Rename rewriting leaves every non-identifier character unchanged
CLI
new, check, eval, fmt, verify, extract, apply, rename.
checkis clean on the examples and reports the expected codes on every invalid fixturecheck --againstfails when the runtime or CSP was modified- Scripted end-to-end: create a file, add a table, add a computed column and a name, confirm the value with
cello eval, all without a browser
Runtime viewer
- Opens from
file://in Chromium, Firefox, and WebKit with zero CSP violations and zero network requests - The grid shows every table, computed column, and name, with invalid values flagged and exposure attributes set
- A broken file shows the diagnostics panel, never a blank page
cello watchreloads the preview within a second of the file changing
Views, print, render
- The invoice example renders, with tag and computed-boolean exposure working
- Invoice print screenshot matches its baseline
- The template allowlist is enforced and interpolated
hrefis rejected cello renderoutput contains no script and matches the runtime's render of the same view
Export, import, upgrade
cello export --compatoutput passesfrictionless validate(frictionless-py) and the v2 JSON Schema profile; the default export differs from it only in list columns- Import then export round-trips the examples
cello upgradeswaps the runtime, updates the CSP, andcheckpasses afterwardGUIDE.mdandskills/cello/SKILL.mddocument the agent editing contract
Complete example
examples/invoice.cello is a one-table invoice with tags, a computed column, input and computed names, an invoice view, and grid styling for rows tagged review. Its values double as an acceptance test.
| Command | Expected output |
|---|---|
cello eval invoice.cello subtotal |
2587.5 |
cello eval invoice.cello tax |
226.41 |
cello eval invoice.cello total |
2813.91 |
cello eval invoice.cello line_total --table lines --row 2 |
787.5 |
cello eval invoice.cello "ROWS(lines)" |
4 |
The Travel line has no billable tag, so it is excluded from the subtotal and the invoice.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'sha256-RUNTIME_HASH'; style-src 'unsafe-inline'; img-src data:; font-src data:; base-uri 'none'; form-action 'none'">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="generator" content="cello 0.1">
<title>Invoice 2026-014</title>
</head>
<body>
<noscript>
<style>script[type="text/csv"]{display:block;white-space:pre;font:13px/1.4 ui-monospace,monospace;margin:1em;padding:1em;border:1px solid #ccc;overflow-x:auto}</style>
<p>This is a cello file. JavaScript is off, so here is the raw data.</p>
</noscript>
<script type="application/json" id="cello-package">
{
"$schema": "https://datapackage.org/profiles/2.0/datapackage.json",
"name": "invoice-2026-014",
"title": "Invoice 2026-014",
"resources": [
{
"name": "lines",
"type": "table",
"path": "lines.csv",
"format": "csv",
"mediatype": "text/csv",
"encoding": "utf-8",
"schema": {
"fields": [
{ "name": "date", "title": "Date", "type": "date" },
{ "name": "item", "title": "Item", "type": "string", "constraints": { "required": true } },
{ "name": "qty", "title": "Qty", "type": "number", "constraints": { "minimum": 0 } },
{ "name": "unit_price", "title": "Unit price", "type": "number", "cello": { "unit": "USD" } },
{
"name": "tags",
"title": "Tags",
"type": "list",
"itemType": "string",
"delimiter": ";",
"cello": { "values": ["billable", "review", "void"] }
}
]
},
"cello": {
"computed": [
{
"name": "line_total",
"title": "Line total",
"type": "number",
"unit": "USD",
"formula": "qty * unit_price"
}
]
}
}
],
"cello": {
"version": "0.1",
"locale": "en-US",
"defaultView": "invoice",
"names": {
"invoice_no": { "title": "Invoice number", "type": "string", "value": "2026-014" },
"client": { "title": "Client", "type": "string", "value": "Acme Co" },
"due_date": { "title": "Due", "type": "date", "value": "2026-10-15" },
"tax_rate": { "title": "Tax rate", "type": "number", "unit": "percent", "value": 0.0875 },
"subtotal": {
"unit": "USD",
"formula": "SUM(FILTER(lines.line_total, HAS(lines.tags, \"billable\")))"
},
"tax": { "unit": "USD", "formula": "ROUND(subtotal * tax_rate, 2)" },
"total": { "unit": "USD", "formula": "ROUND(subtotal + tax, 2)" }
},
"views": [
{
"name": "invoice",
"title": "Invoice",
"queries": {
"billable": { "from": "lines", "where": "HAS(tags, \"billable\")", "sort": [["date", "asc"]] }
}
}
]
}
}
</script>
<script type="text/csv" data-cello-path="lines.csv">
date,item,qty,unit_price,tags
2026-09-02,Discovery workshop,6,225,billable
2026-09-09,Policy review,3.5,225,billable;review
2026-09-16,Travel,1,340,
2026-09-23,Implementation,2,225,billable
</script>
<script type="text/x-cello-template" data-cello-view="invoice">
<header class="head">
<h1>Invoice {{ invoice_no }}</h1>
<p>Bill to: {{ client }}<br>Due {{ due_date | date(long) }}</p>
</header>
<table class="lines">
<thead><tr><th>Date</th><th>Item</th><th class="num">Qty</th><th class="num">Rate</th><th class="num">Amount</th></tr></thead>
<tbody>
<tr c-each="billable"><td>{{ date | date(short) }}</td><td>{{ item }}</td><td class="num">{{ qty }}</td><td class="num">{{ unit_price }}</td><td class="num">{{ line_total }}</td></tr>
<tr c-empty><td colspan="5">No billable lines.</td></tr>
</tbody>
<tfoot>
<tr><td colspan="4">Subtotal</td><td class="num">{{ subtotal }}</td></tr>
<tr><td colspan="4">Tax ({{ tax_rate }})</td><td class="num">{{ tax }}</td></tr>
<tr class="total"><td colspan="4">Total due</td><td class="num">{{ total }}</td></tr>
</tfoot>
</table>
</script>
<style data-cello-view="invoice">
@page { size: letter; margin: 0.75in; }
main[data-cello-view="invoice"] { font: 14px/1.5 system-ui, sans-serif; color: #111; max-width: 8in; }
@media screen { main[data-cello-view="invoice"] { margin: 32px auto; padding: 0 24px; } }
.head h1 { font-size: 24px; margin: 0 0 4px; }
.lines { width: 100%; border-collapse: collapse; margin-top: 24px; }
.lines th, .lines td { padding: 6px 8px; border-bottom: 1px solid #ddd; text-align: left; }
.lines .num { text-align: right; font-variant-numeric: tabular-nums; }
.lines tfoot .total td { font-weight: 700; border-top: 2px solid #111; }
</style>
<style data-cello-view="grid">
[data-tags~="review"] { background: #fff4c2; }
</style>
<script data-cello-runtime="0.9.15">/* runtime bundle */</script>
</body>
</html>
Open questions
- Escape syntax for forbidden raw-text sequences in CSV cells, instead of rejecting them
- A decimal arithmetic mode for money, instead of IEEE doubles plus
ROUND - Cell-level tags (marking one value as an estimate), beyond row-level exposure
- Nested
c-each - Merge rules for several people editing one file at once outside cello.sh, likely a text CRDT per editable block
- A trusted viewer that opens cello files as data without running their embedded runtime
Deep links
A sheet's address may end in #at=<kind>:<target>, naming a place to open at. It is part of the fragment, so it never reaches a server, and it sits beside a link's secret (#k=…&at=…).
| Kind | Example | Opens |
|---|---|---|
view |
view:pnl |
that view |
heading |
heading:pnl/By month, or heading:By month |
the view (named, or the first whose template has that heading), scrolled to the heading |
group |
group:Series A |
the view showing the inputs panel, with that group unfolded (a group off for now included) |
input |
input:price |
that input's row in the inputs panel, its group unfolded |
name |
name:total |
the named value, in a panel listing them where there is one |
table |
table:expenses |
that table |
row, column, cell |
row:expenses[rent], column:expenses.amount, cell:expenses[rent].amount |
the table with that row, column or cell selected; rows are named as edits name them (by key, #n, or column=value) |
comment |
comment:c-8f2a |
the comment, in a page that shows comments |
The place is unfolded where folded, scrolled into sight and marked for a moment. A place that is gone opens the nearest thing still there (its table, else the front view) and says so. In the fragment, only characters that would break it are escaped (#at=group:Series%20A).