opyeb cborlab

cborlab · Notation

Reading CBOR as EDN

How to read and write the RFC 8949 §8 Extended Diagnostic Notation, and the form this tool prints.

EDN (Extended Diagnostic Notation) writes CBOR as text a person can read and copy. It looks like JSON but can also express byte strings, tags, indefinite length and simple values without loss.

Basic forms

CBOREDNMeaning
0x011unsigned integer
0x20-1negative integer
0x43 0x01 0x02 0x03h'010203'byte string
0x63 0x61 0x62 0x63"abc"text string
0x83 0x01 0x02 0x03[1, 2, 3]array
0xa1 0x01 0x02{1: 2}map
0xc1 0x1a 0x65 0x53 0xf1 0x001(1700000000)tag 1 (a time)
0xf9 0x3e 0x001.5Float16 1.5
0xf6nullsimple value
0xf8 0x20simple(32)unnamed simple value

Indefinite length

An item without a length is marked with _. An indefinite array is [_ 1, 2], an indefinite text string (_ "a", "b") and an indefinite map {_ 1: 2}. An empty indefinite array is [_ ].

Floats

Values print in their shortest form, with a decimal point when the value is integral, as in 2.0. NaN prints as NaN, and infinities as Infinity and -Infinity. RFC 8949 allows a suffix such as 1.5_1 to record the width; this tool keeps EDN simple and puts the width in the structure table instead.

Tags

A tag is written number(value): tag 2 (a positive bignum) is 2(h'010000000000000000') and tag 18 (COSE_Sign1) is 18([...]). For bignum tags this tool also shows the computed decimal value in the structure tree.

EDN is a presentation format, not an interchange standard. Two tools may write the same data differently, so compare Hex when you check one against another.

Questions

Can EDN be turned back into CBOR?

The notation can be parsed back, but this tool takes Hex, Base64 and JSON as input. EDN is here to read and copy a result.

Why quote text strings?

To separate text from byte strings the way JSON does; a byte string is written h'..' and the two never blend.

How is it indented?

RFC 8949 describes a single-line form and multi-line layouts are allowed. This tool prints one line so it can be copied whole.

The indefinite preset holds an indefinite array, text string, byte string and map, so every _ form of EDN appears at once.

Open the tool

Written against RFC 8949 (CBOR), RFC 9052 (COSE), RFC 8392 (CWT) and the IANA COSE algorithm registry. Every byte string and key here is synthetic.