The friendly data format for human & machine

Release Status Prerelease (Please help by reviewing the specs and submitting issues!)

Another Encoding Format?

Today's data formats present us with a dilemma: Use text based formats that are bloated and slow, or use binary formats that humans can't read. Wouldn't it be nice to have the benefits of both, and none of the drawbacks?

Twin Formats

Edit Text, Transmit Binary

Encoded data should be easy to read, easy to edit, as well as low-cost to process and transmit.

Concise Encoding accomplishes this using 1:1 compatible twin formats: one in text, and one in binary.

Keep everything in binary while transmitting and storing on machines, then seamlessly convert to/from text only where a human needs to be involved.

Types!

All the types you need

Tired of coercing your data into strings? Concise Encoding supports these types natively:

Examples

All examples are valid Concise Text Encoding documents that can be transparently 1:1 converted to/from Concise Binary Encoding.

Numeric

                
c1
{
    boolean       = @true
    binary-int    = -0b10001011
    octal-int     = 0o644
    decimal-int   = -10000000
    hex-int       = 0xfffe0001
    very-long-int = 100000000000000000000000000000000000009
    decimal-float = -14.125
    hex-float     = 0x5.1ec4p20
    very-long-flt = 4.957234990634579394723460546348e1000000000
    not-a-number  = @nan
    infinity      = @inf
    neg-infinity  = -@inf
}
                
            

String-Like

                
c1
{
    unquoted-str = no_quotes-needed
    quoted-str   = "Quoted strings support escapes: \n \t \27f"
    url          = |r https://example.com/|
    email        = |r mailto:me@somewhere.com|
}
                
            

Other Basic Types

                
c1
{
    uuid      = @f1ce4567-e89b-12d3-a456-426655440000
    date      = 2019-07-01
    time      = 18:04:00.940231541/E/Prague
    timestamp = 2010-07-15/13:28:15.415942344/Z
    na1       = @na:"Error reading DB"
    na2       = @na // Data not available (no reason given)
}
                
            

Containers

                
c1
{
    list          = [1 2.5 "a string"]
    map           = {one=1 2=two today=2020-09-10}
    bytes         = |u8x 01 ff de ad be ef|
    int16-array   = |i16 7374 17466 -9957|
    uint16-hex    = |u16x 91fe 443a 9c15|
    float32-array = |f32 1.5e10 -8.31e-12|
}
                
            

Markup

                
c1
{
    main-view = <View,
        <Image src=|r images/avatar-image.jpg|>
        <Text id=HelloText,
            Hello! Please choose a name!
        >
        <TextInput id=NameInput style={height=40 borderColor=gray} OnChange="\.@@
            HelloText.SetText("Hello, " + NameInput.Text + "!")
        @@",
            Name me!
        >
    >
}
                
            

References

                
c1
{
    // Entire map will be referenced later as $id1
    marked_object = &id1:{
        recursive = $id1
    }
    ref1        = $id1
    ref2        = $id1

    // Reference pointing to part of another document.
    outside_ref = $|r https://xyz.com/document.cte#some_id|
}
                
            

Metadata

                
c1
// Metadata about the entire document
(
    created     = 2019-9-1/22:14:01
    description = "A demonstration"
    version     = "1.1.0"
){
    children = (
        // Metadata about the list of children
        description = "Homer's children"
    )[Bart Lisa Maggie]
}
                
            

Relationships

                
c1 (
    // Marked base resource identifiers used for concatenation.
    // (Stored in metadata because they themselves aren't part of the data)
    rdf = [
        &people:|r https://springfield.gov/people#|
        &e:|r https://example.org/|
    ]
){
    // Map-encoded relationships (the map is the subject)
    $people:homer_simpson = {

        /* $e refers to |r https://example.org/|
         * $e:wife concatenates to |r https://example.org/wife|
         */
        $e:wife = $people:marge_simpson

        // Multiple relationship objects
        $e:regrets = [
            $firing
            $forgotten_birthday
        ]
    }

    // Relationship containers (@[subject predicate object])
    rdf-statements = [
        &marge_birthday:@[$people:marge_simpson $e:birthday 1956-10-01]
        &forgotten_birthday:@[$people:homer_simpson $e:forgot $marge_birthday]
        &firing:@[$people:montgomery_burns $e:fired $people:homer_simpson]

        // Multiple relationship subjects
        @[[$firing $forgotten_birthday] $e:contribute $e:marital_strife]
    ]
}
                
            

Constants

                
c1
{
    /* Given: Actual type and value of "eggshell" and
     *        "navy-blue" have been defined in a schema
     */
    wall_color = #eggshell
    door_color = #navy-blue
}
                
            

Custom Types

                
c1
{
    // Custom types are user-defined, with user-supplied codecs.
    custom-text   = |ct cplx(2.94+3i)|
    custom-binary = |cb 04 f6 28 3c 40 00 00 40 40|
}
                
            

See the Resources page or Github page for more information.