Open-source project
immutable-js/immutable-js avatar
immutable-js/immutable-js

Immutable.js: Persistent Data Structures for JavaScript

Immutable persistent data collections for Javascript which increase efficiency and simplicity.

33,014 stars1,869 forksTypeScriptMIT

At a glance

What is it?
Immutable.js provides persistent, structurally shared collections for JavaScript. This review covers its mechanism, setup, TypeScript considerations, and where it still fits in a modern ecosystem.
Who is it for?
Adopt Immutable.js if you need persistent, structurally shared collections with a mature API and you accept the cost of a separate data model. Avoid it if you prefer native JavaScript collections and can rely on structural sharing libraries or on language-level features.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 2 days ago.
What is it written in?
Mainly TypeScript, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 23, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • immutable-js/immutable-js33,014 ★ · -25
Star history
Repository2026-08-182026-11-23
immutable-js/immutable-js33k33k

-25 Stars in the last 97 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

What Immutable.js Actually Solves

Immutable.js solves a specific problem: mutable state that leaks across your application. JavaScript objects and arrays are mutable by default, which forces defensive copying and careful tracking of who changed what. The library provides persistent data structures, meaning operations like set or delete return a new collection while sharing structure with the old one. This makes it possible to treat data as values that never change, which simplifies change detection and memoization. The target audience is developers building state-heavy applications, particularly with React and Flux, where data flows down from a single source and components re-render when references change. The README makes this alignment explicit, noting that immutable data aligns well with React's architecture. It is not a general-purpose replacement for all data handling; it is a tool for state management where immutability is a design requirement.

The Mechanism: Hash Array Mapped Tries and Vector Tries

The efficiency of Immutable.js comes from structural sharing via hash array mapped tries and vector tries, concepts popularized by Clojure and Scala. Instead of copying an entire collection on every update, the library creates a new root node that points to unchanged subtrees. Only the path to the modified element is recreated. This gives near-constant time updates for maps and lists, and it minimizes memory overhead compared to naive deep cloning. The README states that these structures are highly efficient on modern JavaScript VMs, which is a claim about the design rather than a benchmark. The practical effect is that you can write code that appears to create new collections on every change, but the underlying cost is proportional to the depth of the tree, not the size of the collection. This is the core mechanism that makes persistent immutability viable in a language without built-in support.

JavaScript-First API: Familiar Methods, New Semantics

The API is designed to feel like native JavaScript collections. You use methods like get, set, map, and filter, which are familiar from arrays and objects. The key difference is that these methods return new collections instead of mutating in place. The README gives a simple example: a Map created with Map({ a: 1, b: 2, c: 3 }) can be updated with map1.set('b', 50), and map1.get('b') still returns 2 while map2.get('b') returns 50. This is a departure from native Map, where set mutates the original. The library also provides List, Stack, OrderedMap, Set, OrderedSet, and Record, each with semantics that match their names. The learning curve is not the method names; it is the mental model of treating every operation as producing a new value. For developers used to mutation, this requires a shift in how they think about data flow, but the API itself is approachable.

Getting Started: Installation and TypeScript Configuration

Installation is straightforward. The README shows npm install immutable, yarn add immutable, pnpm add immutable, and bun add immutable. The module has no dependencies, which makes it predictable in a browser environment. For TypeScript, version 4.5 or higher is required, and the type definitions are included with the package. There is a specific constraint: the type definitions embrace ES2015, so your tsconfig.json must include either "target": "es2015" or "lib": "es2015". If you are on TypeScript with Immutable.js v4 or later, you need to set that. For v3 and earlier, you would include a reference file via a relative path. This is a real configuration detail that can trip up new users, especially if they are on an older TypeScript target. The README also mentions Flow support for v0.55.0 or higher, so the library covers both typing systems.

Equality, Values, and the is() Function

A central principle in the README is that Immutable collections should be treated as values, not objects. This means equality should be based on the content of the collection, not on reference identity. The library provides the Immutable.is() function for this purpose, which compares collections by their values. The README says to use Immutable.is() or the .equals method to check equality. This is important for memoization and change detection: you can compare two maps by their contents rather than by reference. However, this value-based equality is not automatic. If you use the native === operator, you will get reference equality, which defeats the purpose. This is a subtle point that the documentation emphasizes, and it is a common source of bugs for new users. The trade-off is that you must be disciplined about using the provided equality functions.

Batching Mutations and Lazy Seq

The README mentions two features that address performance and expressiveness. The first is batching mutations, which appears as a Batching Mutations section in the README's table of contents. The second is the lazy Seq, which allows chaining methods like map and filter without creating intermediate representations. You can create a Seq with Range and Repeat, and the operations are evaluated lazily. This is a significant efficiency gain for large data sets, because it avoids building multiple temporary arrays. The lazy Seq is a distinctive feature that sets Immutable.js apart from simple immutable wrappers. It is not a trivial addition; it changes how you think about collection pipelines.

Limitations and When It Is the Wrong Tool

The main limitation is that Immutable.js collections are not native JavaScript collections. You cannot pass an Immutable Map directly to code that expects a plain object or a native Map. You need conversion functions, such as toObject() or toJS(), which add overhead and create a boundary between your immutable core and the rest of the ecosystem. This is a real cost, especially in a large codebase where many libraries expect plain data. Another limitation is the TypeScript configuration requirement: if you cannot set your TypeScript target or lib to es2015, the v4 and later type definitions will not work. The library also has a long history, with releases spanning v3.8.4, v5.1.9, and a v6.0.0-beta.1 as of August 2026. The v6 beta suggests ongoing development, but it also means you may be on a beta if you want the latest features. For small projects or simple state management, the overhead of learning a separate data model may not be worth it. If your data is mostly read-only and you rarely need to update nested structures, a plain object with Object.freeze might be sufficient.

Alternatives: Immer and Native Structural Sharing

The most direct alternative is Immer, which takes a different approach. Instead of providing persistent data structures, Immer lets you work with plain JavaScript objects and arrays, and it uses a proxy-based mechanism to record mutations. You write code that appears to mutate a draft, and Immer produces a new immutable state. This means you keep your existing data types and you do not need a conversion layer. The trade-off is that Immer does not provide structural sharing in the same way; it uses copy-on-write on the modified paths, which is similar in spirit but implemented differently. Another alternative is to use native JavaScript features like Object.freeze combined with structuredClone, but these do not give you the same efficiency for updates. The choice between Immutable.js and Immer often comes down to whether you prefer a dedicated collection API or a more transparent proxy-based approach. Immutable.js has a longer history and a more explicit API, while Immer integrates more smoothly with existing codebases.

Maintenance, Upgrades, and License

The repository shows active maintenance, with a v6.0.0-beta.1 pushed on August 16, 2026, and a v3.8.4 release two days earlier, on August 14. This indicates that the project still supports older major versions, which is a positive sign for maintenance. The latest stable release is v5.1.9 from June 2026. Upgrading between major versions can involve breaking changes, especially in type definitions. The README notes that v4 and later require TypeScript es2015, which is a significant change from v3. The license is MIT, which is permissive and allows commercial use without restrictions. There is no indication of a copyleft obligation. For upgrade cost, you should review the changelog for each major version, but the fact that v3 is still receiving patches suggests that the maintainers care about backward compatibility. The v6 beta is a signal that the project is not stagnant, but you should not adopt a beta in production without testing.

Editorial conclusion

Adopt Immutable.js if you need persistent, structurally shared collections with a mature API and you accept the cost of a separate data model. Avoid it if you prefer native JavaScript collections and can rely on structural sharing libraries or on language-level features. Before adopting, verify the v6 beta's stability against your workload, confirm your TypeScript target meets the es2015 requirement, and check that your team can handle the conversion layer between immutable and plain data. The library remains a solid, dependency-free choice for state-heavy React and Flux applications, but it is not the only path to immutability.

Frequently asked questions

What is Immutable.js?

Immutable.js provides persistent data collections for JavaScript, including List, Stack, Map, OrderedMap, Set, OrderedSet and Record, plus a lazy Seq. Data cannot be changed once created, and the mutative API yields new updated data rather than writing in place.

Is Immutable.js still used?

The last push to the repository was on 2026-11-01, and three tags were released in 2026: v5.1.9 on 2026-06-29, v3.8.4 on 2026-08-14 and v6.0.0-beta.1 on 2026-08-16. The project points contributors at a Slack workspace, a wiki of articles on specific topics, and its issue tracker.

Does Immutable.js need extra setup for TypeScript?

Installing it with npm brings type definitions for Flow v0.55.0 or higher and for TypeScript v4.5 or higher, so nothing extra is needed to begin. The v4 and later definitions require an ES2015 target or lib, either as "target": "es2015" or "lib": "es2015" in tsconfig.json, or as --target es2015 or --lib es2015 on the tsc command.

What does the Immutable.js npm package actually ship?

The files field limits the published tarball to dist, README.md and LICENSE, so src/ and __tests__/ stay in the repository only. main resolves to dist/immutable.js, module to dist/immutable.es.js and types to dist/immutable.d.ts.

What is a Seq in Immutable.js and when should one be avoided?

Seq is the lazy collection, so chaining map and filter across it creates no intermediate representation, and Range and Repeat are given as the ways to build one.

Official sources

  1. Official documentation
  2. Official README
  3. Project repository
  4. Release notes
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/immutable-js-immutable-js.svg)](https://hysenlabs.com/projects/immutable-js-immutable-js)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/immutable-js-immutable-js.svg)](https://hysenlabs.com/projects/immutable-js-immutable-js)

Was this useful?