GUN
activeby Mark Nadal and contributors · since 2014 · also known as GUN.js, gun.eco
Decentralised, offline-first graph database that syncs peer-to-peer in JavaScript.
Overview
GUN is a small JavaScript graph database where every browser or Node process is a peer: data is a graph of nodes merged with a CRDT-like conflict algorithm (HAM), replicated over WebSockets, WebRTC or relay peers, and persisted locally (RAD storage on disk or IndexedDB). The SEA module adds user accounts, signing and encryption in user space. It is popular for hobby decentralised apps, chat and experiments because it needs no central server. It has no transactions, a quirky API, thin documentation, and eventual consistency that makes it unsuitable for data needing invariants.
Strengths & trade-offs
Strengths
- +Serverless peer-to-peer sync with offline writes
- +Realtime subscriptions on any node in the graph
- +User-space crypto (SEA) for signed and encrypted data
- +Tiny footprint; runs in browsers and Node
Trade-offs
- −No transactions or constraints; last-writer semantics per field
- −Sparse documentation and an unusual API
- −Hard to reason about data availability across peers
Great for
- +Decentralised chat and social experiments
- +Hackathon and prototype realtime apps
- +Offline-capable apps without a central server
Think twice for
- −Financial or inventory data needing invariants
- −Large datasets or complex queries
- −Regulated workloads needing auditability
Capabilities
Native or official first-party support · 4 of 25 tracked
Scale & consistency
- Comfortable data size
- Small · ≤ 100 GB
- Horizontal scaling
- Manual
- Multi-region
- Active active
- Transactions
- None
- Consistency
- Eventual
- Schema
- Schemaless
- Architecture
- Distributed, Multi primary, Embedded
- Query languages
- GUN chain API
Peers replicate the subgraphs they subscribe to; there is no sharding or global coordination.
Deployment
Ecosystem
Alternatives to GUN
Serverless peer-to-peer database on IPFS and libp2p using Merkle-CRDT logs.
gun vs orbitdb →JavaScript database for browsers and Node that speaks the CouchDB replication protocol.
gun vs pouchdb →Local-first database with built-in sync, permissions and edit history, being rebuilt as a relational Jazz 2.
gun vs jazz →Tiny reactive in-memory store for tables and values, with persisters and CRDT sync.
gun vs tinybase →Reactive local-first NoSQL database for JavaScript with pluggable storage and replication.
gun vs rxdb →Immutable in-memory database with Datomic-style Datalog queries for Clojure, ClojureScript and JavaScript.
gun vs datascript →GUN FAQ
What is GUN?
GUN is a graph database by Mark Nadal and contributors, first released in 2014. GUN is a small JavaScript graph database where every browser or Node process is a peer: data is a graph of nodes merged with a CRDT-like conflict algorithm (HAM), replicated over WebSockets, WebRTC or relay peers, and persisted locally (RAD storage on disk or IndexedDB). The SEA module adds user accounts, signing and encryption in user space. It is popular for hobby decentralised apps, chat and experiments because it needs no central server. It has no transactions, a quirky API, thin documentation, and eventual consistency that makes it unsuitable for data needing invariants.
Is GUN open source?
Yes. GUN is open source. License: Zlib, MIT or Apache-2.0 (choice).
Does GUN support ACID transactions?
No. GUN does not provide ACID transactions; its consistency model is eventual.
Does GUN scale horizontally?
GUN has no built-in sharding; scaling out means partitioning data in your application. It is comfortable at small scale (≤ 100 GB). It supports active-active multi-region writes.
How can I run GUN?
You can self-host it, embed it in your application and run it at the edge.
What is GUN best for?
GUN is a strong fit for decentralised chat and social experiments; hackathon and prototype realtime apps; and offline-capable apps without a central server. Think twice for financial or inventory data needing invariants.
What are the best alternatives to GUN?
Common alternatives to GUN include OrbitDB, PouchDB, Jazz, TinyBase and RxDB. The right choice depends on your workload, scale and hosting; WhichDB's smart match ranks them against your requirements.
How popular is GUN?
GUN ranks #111 of 844 databases on the WhichDB Score (26.6/100), and #7 among graph databases. The score combines public adoption signals such as package downloads, GitHub activity, job posts and developer discussion.



