Star

Persistent, immutable data structures for JavaScript / TypeScript

List Map Set Record and a lazy Seq — highly efficient, with zero dependencies and TypeScript types in the box.

$ npm install immutable
The collection family

Several persistent collections, one familiar API

Why Immutable.js

Built to make data simpler and faster

Performance
Fast & memory-light
New versions reuse the parts that didn't change — cheap to create, and the original is never touched. No defensive copying.
Lazy Seq
Chaining without cost
Chain map, filter and more — even over infinite ranges — with zero intermediate arrays.
State
Simpler application state
Data never mutates under you, so undo/redo, change detection and memoization become trivial. A natural fit for React & Redux.
fromJS / toJS
Interop with plain JS
Convert to and from objects & arrays, shallow or deep, in a single call.
getIn / setIn / updateIn
Deep, without the pain
Read and update values buried deep in nested structures with a path.
TypeScript
Typed out of the box
First class TypeScript support: full generics, error detection and editor auto-complete — nothing to install.

Examples

Build & transform a List — every call returns a new List
const upperFirst = (str) =>
  str.charAt(0).toUpperCase() + str.slice(1);

List(['apple', 'banana', 'coconut'])
  .push('dragonfruit')
  .map((fruit) => upperFirst(fruit));
// → List [ "Apple", "Banana", "Coconut", "Dragonfruit" ]
Live & editable

Every example runs, right here

Edit the code and press Run. No install, no setup — the same interactive editor appears throughout the docs so you can learn by trying.

Open the full Playground →