C0DATA

Structure data with ASCII control codes.
One vocabulary, multiple shapes.

Between text formats and binary formats — values are UTF-8, structure is single bytes

JSON 198 bytes
{
  "users": [
    {"name": "Alice", "amount": "1502.30"},
    {"name": "Bob", "amount": "340.00"}
  ],
  "products": [
    {"id": "01", "product": "Widget"},
    {"id": "02", "product": "Gadget"}
  ]
}
C0DATA 91 bytes
␜mydb
  ␝users
    ␁␞name␟amount
    ␞Alice␟1502.30
    ␞Bob␟340.00
  ␝products
    ␁␞id␟product
    ␞01␟Widget
    ␞02␟Gadget
␄

Each glyph is a single-byte control code. No braces, no quotes; a value that needs them is fenced by two bytes, ␂…␃.

␜ File
›
␝ Group
›
␞ Record
›
␟ Unit

Four hierarchical data separators — the same ones the ASCII committee designed in 1963.

How It Works

ASCII has 32 control codes (0x00–0x1F) designed for structuring data. C0DATA assigns meaning to 16 of them.

GlyphByteAbbrRole
␜0x1CFSFile separator
␝0x1DGSGroup / table / section separator; repeated for depth
␞0x1ERSRecord / row separator
␟0x1FUSUnit / field separator
␁0x01SOHKey (␁key␟value) or header row (␁␞)
␂0x02STXOpen text
␃0x03ETXClose text
␐0x10DLEOpen a nested level; inside text, escape the next code
␘0x18CANClose a nested level
␅0x05ENQReference (look up named data)
␇0x07BELComment, or dead marker before an element
␖0x16SYNStart of document; heading follows
␄0x04EOTEnd of document
␗0x17ETBCommit marker (stream logs)
␙0x19EMEnd of medium; raw blob follows
␚0x1ASUBSubstitution (C0-DIFF)

Multiple Shapes

The same codes express every common data shape.

// Like CSV or SQL tables
␝users
  ␁␞name␟amount␟type
  ␞Alice␟1502.30␟DEPOSIT
  ␞Bob␟340.00␟WITHDRAWAL
// Like TOML or INI: a keyed record is a map
␝database
  ␞␁host␟localhost␁port␟5432
␝server
  ␞␁host␟0.0.0.0␁port␟8080
// Like Markdown sections
␜My Document
  ␝Chapter 1
    ␞First paragraph of text.
    ␞A list:␟␐
      ␞Item one␟Item two
    ␘
    ␝␝Section 1.1
      ␞Nested content.
// Atomic multi-file edits
␖␁shape␟diff
␜foo.txt
  ␝␂Hello ␃␟world␚universe␟!

// Find "Hello world!", replace "world" → "universe"

Benchmarks

Single-byte delimiters. Zero-copy parsing. The hot loop is one comparison: byte < 0x20.

1,928
MB/s tokenizer
~3x
smaller than JSON

Format Size (10K rows, 5 fields)

C0DATAc
506 KB
CSV
526 KB
C0DATAp
636 KB
YAML
966 KB
JSON
1,476 KB

c compact — canonical wire/storage form   p pretty — human-readable with Unicode glyphs

Parse (format → data)

C0DATAc
0.4 ms
C0DATAp
2.7 ms
CSV
3.4 ms
JSON
9.0 ms
YAML
27.5 ms

c Zero-copy — no parsing or allocation.
Fields are byte slices into the original buffer.

Serialize (data → format)

C0DATAc
0.8 ms
C0DATAp
1.2 ms
CSV
5.7 ms
JSON
9.5 ms
YAML
24.8 ms

Benchmarks on Intel Core Ultra 7 155H, 16 GB RAM, Crystal 1.19.1 compiled with --release. Tokenizer benchmark on 10 MB synthetic document. Conversion benchmarks on 10,000-row table (506 KB C0DATA). Measured on the 0.x format; the 1.0 hot loop is unchanged and the numbers will be re-run when the ports land.

Get Started

Seven implementations, one spec, one shared conformance suite. The Crystal reference is shown below; every port has the same builder and zero-copy reader.

Implementations & API docs

Crystal  reference     c0data/c0-cr   API docs
TypeScript             c0data/c0-js   API docs
Rust     zero-dep      c0data/c0-rs   docs.rs
Go       pure Go       c0data/c0-go   pkg.go.dev
C        single header c0data/c0-c    API docs
Python   C extension   c0data/c0-py   API docs
Ruby     C extension   c0data/c0-rb   API docs
Editors  VS Code       c0data/c0-ed
CLI      c0fmt         c0data/c0-fmt

Install

# the package is c0data everywhere; in code it is c0
npm    install c0data
cargo  add c0data            # use c0::…
gem    install c0data        # require "c0"
pip    install c0data-py     # import c0
go     get github.com/c0data/c0-go
# shard.yml
dependencies:
  c0:
    github: c0data/c0-cr

Build data

buf = C0::Builder.build do |b|
  b.syn(version: "1")
  b.group("users", ["name", "amount"])
  b.record("Alice", "1502.30")
  b.record("Bob", "340.00")
  b.eot
end

Read data

doc = C0::Document.new(buf)
doc["users"].record(0).value(0)  # => "Alice" (zero-copy slice)

Convert formats

# Command line
c0fmt import data.csv | c0fmt export json
c0fmt import config.json | c0fmt pretty
c0fmt import yaml settings.yml | c0fmt compact -o data.c0

Build c0fmt

# c0fmt lives in its own repo: c0data/c0-fmt
git clone https://github.com/c0data/c0-fmt && cd c0-fmt
shards build --release   # → bin/c0fmt