PAKT — a typed data interchange format. Human-authorable. Streaming. Self-describing.
greeting:str = 'hello world'
count:int = 42
payload:bin = x'48656C6C6F'
active:bool = true
server:{host:str, port:int} = { 'localhost', 8080 }
PAKT is a typed data interchange format where every value carries its type. No inference, no ambiguity. Units are self-validating — type annotations are producer assertions checked at parse time.
The current Go library and CLI implement the PAKT v0 surface: ; map syntax, bin, raw strings, the first-content-line multi-line string rule, and top-level << pack statements. Duplicate statement names and map keys are preserved in decode order; higher-level consumers decide how to interpret them.
pakt/
├── encoding/ # Canonical Go library (github.com/trippwill/pakt/encoding)
├── dotnet/ # .NET library, source generator, benchmarks
├── main.go # CLI entry point (go install github.com/trippwill/pakt@latest)
├── spec/ # Formal specification (PAKT v0 draft)
├── docs/ # User guide and documentation
├── site/ # Hugo website (usepakt.dev)
└── testdata/ # Sample .pakt files
go install github.com/trippwill/pakt@latest# Parse a file and emit structured events
pakt parse data.pakt
# Validate only (exit 0/1)
pakt validate data.paktimport"github.com/trippwill/pakt/encoding"typeConfigstruct {
Hoststring`pakt:"host"`Portint`pakt:"port"`
}
cfg, err:= encoding.UnmarshalNew[Config](data)ur:=encoding.NewUnitReader(reader)
deferur.Close()
forprop:=rangeur.Properties() {
switchprop.Name {
case"config":
cfg, err:= encoding.ReadValue[Config](ur)
case"events":
forevent:=range encoding.PackItems[LogEvent](ur) {
process(event)
}
}
}
iferr:=ur.Err(); err!=nil { ... }dec:=encoding.NewDecoder(reader)
deferdec.Close()
for {
ev, err:=dec.Decode()
iferr==io.EOF { break }
fmt.Println(ev.Kind, ev.Name, string(ev.Value))
}The dotnet/ directory contains a high-performance .NET implementation with source-generated serialization. See dotnet/README.md for full details.
usingPakt;usingPakt.Serialization;[PaktSerializable(typeof(Server))]publicpartialclassAppPaktContext:PaktSerializerContext{}// Deserialize a unit with top-level statements matching CLR propertiesvarserver=PaktSerializer.Deserialize<Server>(paktBytes,AppPaktContext.Default);// Iterate pack statementsusingvarreader=PaktMemoryReader.Create(paktBytes,AppPaktContext.Default);while(reader.ReadStatement()){if(reader.IsPack&&reader.StatementType.IsList){foreach(variteminreader.ReadPack<Server>())Process(item);}elseif(reader.IsPack&&reader.StatementType.IsMap){foreach(variteminreader.ReadMapPack<string,Server>())Console.WriteLine($"{item.Key}: {item.Value.Host}:{item.Value.Port}");}else{varvalue=reader.ReadValue<Server>();Console.WriteLine($"{value.Host}:{value.Port}");}}- PAKT Specification — formal grammar and semantics
- PAKT Guide — human-friendly introduction
- usepakt.dev — website