slab/delta sits at 1.0k stars on GitHub, written primarily in TypeScript. Simple and expressive JSON format for describing rich-text content and their changes
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
Deltas are a simple, yet expressive format that can be used to describe contents and changes. The format is JSON based, and is human readable, yet easily parsible by machines. Deltas can describe any rich text document, includes all text and formatting information, without the ambiguity and complexity of HTML.
A Delta is made up of an Array of Operations, which describe changes to a document. They can be an insert, delete or retain. Note operations do not take an index. They always describe the change at the current index. Use retains to "keep" or "skip" certain parts of the document.
Don’t be confused by its name Delta—Deltas represents both documents and changes to documents. If you think of Deltas as the instructions from going from one document to another, the way Deltas represent a document is by expressing the instructions starting from an empty document.
Quick Example
// Document with text "Gandalf the Grey"
// with "Gandalf" bolded, and "Grey" in grey
const delta = new Delta([
{ insert: 'Gandalf', attributes: { bold: true } },
{ insert: ' the ' },
{ insert: 'Grey', attributes: { color: '#ccc' } }
]);
// Change intended to be applied to above:
// Keep the first 12 characters, insert a white 'White'
// and delete the next four characters ('Grey')
const death = new Delta().retain(12)
.insert('White', { color: '#fff' })
.delete(4);
// {
// ops: [
// { retain: 12 },
// { insert: 'White', attributes: { color: '#fff' } },
// { delete: 4 }
// ]
// }
// Applying the above:
const restored = delta.compose(death);
// {
// ops: [
// { insert: 'Gandalf', attributes: { bold: true } },
// { insert: ' the ' },
// { insert: 'White', attributes: { color: '#fff' } }
// ]
// }
This README describes Deltas in its general form and API functionality. Additional information on the way Quill specifically uses Deltas can be found on its own Delta docs. A walkthough of the motivation and design thinking behind Deltas are on Designing the Delta Format.
This format is suitable for Operational Transform and defines several functions to support this use case.
Contents
Operations
insert
delete
retain
Construction
constructor
insert
delete
retain
Documents
These methods called on or with non-document Deltas will result in undefined behavior.
concat
diff
eachLine
invert
Utility
filter
forEach
length
map
partition
reduce
slice
Operational Transform
compose
transform
transformPosition
Operations
Insert Operation
Insert operations have an insert key defined. A String value represents inserting text. Any other type represents inserting an embed (however only one level of object comparison will be performed for equality).
In both cases of text and embeds, an optional attributes key can be defined with an Object to describe additonal formatting information. Formats can be changed by the retain operation.
Delete operations have a Number delete key defined representing the number of characters to delete. All embeds have a length of 1.
// Delete the next 10 characters
{ delete: 10 }
Retain Operation
Retain operations have a Number retain key defined representing the number of characters to keep (other libraries might use the name keep or skip). An optional attributes key can be defined with an Object to describe formatting changes to the character range. A value of null in the attributes Object represents removal of that key.
Note: It is not necessary to retain the last characters of a document as this is implied.
// Keep the next 5 characters
{ retain: 5 }
// Keep and bold the next 5 characters
{ retain: 5, attributes: { bold: true } }
// Keep and unbold the next 5 characters
// More specifically, remove the bold key in the attributes Object
// in the next 5 characters
{ retain: 5, attributes: { bold: null } }
Construction
constructor
Creates a new Delta object.
Methods
new Delta()
new Delta(ops)
new Delta(delta)
Parameters
ops - Array of operations
delta - Object with an ops key set to an array of operations
Note: No validity/sanity check is performed when constructed with ops or delta. The new delta's internal ops array will also be assigned from ops or delta.ops without deep copying.
Example
const delta = new Delta([
{ insert: 'Hello World' },
{ insert: '!', attributes: { bold: true }}
]);
const packet = JSON.stringify(delta);
const other = new Delta(JSON.parse(packet));
const chained = new Delta().insert('Hello World').insert('!', { bold: true });
insert()
Appends an insert operation. Returns this for chainability.
Returns a Delta representing the difference between two documents. Optionally, accepts a suggested index where change took place, often representing a cursor position before change.
Methods
diff(other)
diff(other, index)
Parameters
other - Document Delta to diff against
index - Suggested index where change took place
Returns
Delta - difference between the two documents
Example
const a = new Delta().insert('Hello');
const b = new Delta().insert('Hello!');
const diff = a.diff(b); // { ops: [{ retain: 5 }, { insert: '!' }] }
// a.compose(diff) == b
eachLine()
Iterates through document Delta, calling a given function with a Delta and attributes object, representing the line segment.
Returns a Delta that is equivalent to applying the operations of own Delta, followed by another Delta.
Methods
compose(other)
Parameters
other - Delta to compose
Example
const a = new Delta().insert('abc');
const b = new Delta().retain(1).delete(1);
const composed = a.compose(b); // composed == new Delta().insert('ac');
transform()
Transform given Delta against own operations.
Methods
transform(other, priority = false)
transform(index, priority = false) - Alias for transformPosition
Parameters
other - Delta to transform
priority - Boolean used to break ties. If true, then this takes priority
over other, that is, its actions are considered to happen "first."
Returns
Delta - transformed Delta
Example
const a = new Delta().insert('a');
const b = new Delta().insert('b').retain(5).insert('c');
a.transform(b, true); // new Delta().retain(1).insert('b').retain(5).insert('c');
a.transform(b, false); // new Delta().insert('b').retain(6).insert('c');
transformPosition()
Transform an index against the delta. Useful for representing cursor/selection positions.
TopGit's last sync did not record any GitHub topics for slab/delta. GitHub topics appear in the right sidebar of a repository page; that's the authoritative place to check.
How active is development on slab/delta?
The most recent commit recorded on slab/delta was 2.4 years ago, based on the GitHub push timestamp. The repository has 142 forks — one of the better signals of community interest.
How many stars does slab/delta have?
slab/delta has 1.0k GitHub stars — refresh the page for the live number, or check github.com/slab/delta. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
What language is slab/delta written in?
slab/delta is written primarily in TypeScript. GitHub's language field is based on the largest share of bytes in the default branch.
What license does slab/delta use?
slab/delta is released under the BSD-3-Clause license. Always verify the LICENSE file directly on GitHub for the authoritative terms — license strings can be edited out of sync with a project's actual stance.
Where can I see slab/delta in action?
The project maintains a homepage at https://quilljs.com/docs/delta. The README tab on this page also usually contains screenshots and a quickstart.
Where do I read more about slab/delta?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/slab/delta is the definitive source.
Read full README in the tab above.
Curious whether delta is right for you?
Let ChatGPT, Claude, or Perplexity look into it — click below and see what AI actually says about delta.