Format at a glance

SFlat (Structured Flat Data) is a human-readable, line-oriented, schema-first typed flat-file format: a deterministic alternative to CSV that also supports binary payloads.

Annotated SFlat example

SFlat documents are UTF-8 and LF-only. A document starts with a header block, followed by a blank line, then the body.

#!sflat 0.2
Profile: text
Layout: row
Body-Encoding: text
Records: 2
Schema: Name:str(50):req;Age:int32:opt;Joined:date:req

--Alice,35,2024-01-15
--Bob,\N,2024-03-02
Line or token Meaning
#!sflat 0.2 Format declaration and version.
Profile: text Text profile for typed rows; the alternative is the Payload profile for binary or large data.
Body-Encoding: text / Layout: row Declares how the body is encoded and laid out.
Records: 2 Declared record count, validated against the body.
Schema: ... Typed field definitions written as name:type:presence, separated by ;; presence is req or opt.
Blank line Terminates the header block; the body follows.
--Alice,35,2024-01-15 A record line using the -- prefix and comma-separated fields.
\N Explicit null, shown here for the optional Age field.

Optional Body-Bytes and Body-Hash: sha256:... headers add integrity checks. The Payload profile adds bytes fields carried inline with #b or as #p payloads for larger or binary data.

For a fuller public summary of profiles, payloads, hints, integrity headers, and v0.2 changes, see the v0.2 standard page.

Scalar types

Type Description
str(n) Unicode text up to n characters.
bool true / false.
int32 32-bit signed integer.
int64 64-bit signed integer.
float64 IEEE-754 double (finite).
decimal(p,s) Fixed-precision decimal (precision p, scale s).
uuid Canonical lowercase UUID.
date Calendar date (YYYY-MM-DD).
time Time of day.
local-datetime Date-time without offset.
instant UTC instant.
offset-datetime Date-time with UTC offset.
bytes Binary data (Payload profile).