Last updated
What Is EDN?
EDN (Extensible Data Notation) is a data format created by Rich Hickey for the Clojure ecosystem. It's similar to JSON but richer: it supports more data types natively, including keywords, symbols, sets, tagged literals, and arbitrary precision numbers. EDN is used as the data format for Datomic databases, ClojureScript transit, and many Clojure libraries.
EDN vs JSON
| Feature | JSON | EDN |
|---|---|---|
| Strings | "hello" | "hello" |
| Numbers | 42, 3.14 | 42, 3.14, 42N (BigInt), 3.14M (BigDecimal) |
| Booleans | true, false | true, false |
| Null | null | nil |
| Arrays | [1, 2, 3] | [1 2 3] (vector) |
| Objects | {"key": "val"} | {:key "val"} (map with keyword) |
| Keywords | Not supported | :keyword, :ns/keyword |
| Sets | Not supported | #{1 2 3} |
| Comments | Not supported | ; line comment |
| Tagged literals | Not supported | #inst "2026-03-22" |
EDN Example
; User record in EDN
{:id 42
:name "Alice"
:email "alice@example.com"
:roles #{:admin :user}
:created-at #inst "2026-01-15T10:30:00Z"
:settings {:theme :dark
:notifications true
:items-per-page 25}}
Reading EDN in Clojure
(require '[clojure.edn :as edn])
; Parse EDN string
(edn/read-string "{:name "Alice" :age 30}")
; => {:name "Alice", :age 30}
; Read from file
(with-open [r (java.io.PushbackReader. (clojure.java.io/reader "data.edn"))]
(edn/read r))