What is a CRDT? Replicated Data Types Explained
A CRDT (conflict-free replicated data type) is a data structure where multiple copies can be edited independently and always merged into a consistent result, without a central server coordinating changes. If two people edit the same document on different devices — even offline — CRDTs guarantee that both edits are preserved and the documents converge to the same state when they reconnect.
How CRDTs work
Traditional collaborative editing depends on a central server. Every change goes through that server, which decides the final order of operations. If the server goes down, editing stops.
CRDTs flip this model. Each user holds a full copy of the data. Edits happen locally, with no round-trip to a server. When devices reconnect, the copies sync by exchanging their changes, and the CRDT's merge function combines them into an identical result on every device.
This works because CRDTs encode mathematical properties into the data structure itself. The two main families are:
- State-based CRDTs (CvRDTs): each replica sends its full state, and a merge function combines any two states into one. The merge is commutative, associative, and idempotent — meaning order doesn't matter, grouping doesn't matter, and applying the same state twice has no effect.
- Operation-based CRDTs (CmRDTs): replicas send individual operations (like "insert character 'a' at position 5"). The operations are designed so they can be applied in any order and still produce the same result.
Modern CRDT libraries like Loro combine ideas from both approaches and add optimizations for specific data types like rich text, lists, trees, and maps.
Why CRDTs matter
The shift toward local-first software — where your data lives on your device, not on someone else's server — is making CRDTs increasingly relevant.
Three properties set them apart:
- Offline editing: make changes without an internet connection and sync when you reconnect.
- No single point of failure: the system keeps working without a central server being online.
- Guaranteed consistency: every replica converges to the same state, by mathematical construction. No "your changes were overwritten" dialogs.
For anyone building tools where multiple people or multiple devices edit the same data, CRDTs replace fragile strategies like locking the document or last-writer-wins with a sound structural guarantee.
CRDTs in practice
CRDTs power real production systems across several categories:
- Collaborative editors: Figma's multiplayer design tool uses CRDT-inspired data structures for real-time collaboration. The Zed code editor uses CRDTs for multi-user editing sessions.
- Distributed databases: Redis uses CRDTs in its active-active geo-distributed database to resolve conflicts across data centers. Riak was an early pioneer of the approach.
- Local-first apps: CoCube uses the Loro CRDT library to store every document as a conflict-free replicated data structure. Edits happen locally and sync between devices through binary CRDT snapshots and incremental operations — whether you're online or off.
CRDTs vs Operational Transformation
Operational Transformation (OT) is the older approach to collaborative editing, most famously used by Google Docs. OT requires a central server to transform and reorder operations. CRDTs don't.
| CRDTs | OT | |
|---|---|---|
| Central server required | No | Yes |
| Offline editing | Built-in | Limited |
| Complexity | In the data structure | In the transform functions |
| Proven at scale | Growing (Figma, Redis) | Mature (Google Docs) |
OT is battle-tested for server-centric architectures. CRDTs are the better fit when a central server is a limitation, not a feature — peer-to-peer systems, offline-capable apps, and local-first tools that put the user's device first.
Related terms
- Local-first software: applications that store data on the user's device and sync in the background, often using CRDTs for conflict resolution.
- Eventual consistency: a consistency model where all replicas converge to the same state given enough time. CRDTs guarantee this by construction.
- Operational Transformation (OT): an alternative approach for collaborative editing that relies on a central server to order and transform operations.