
Immutable.js
JavaScript libraries for immutable data collections that never change once created.
- Stars
- 33k
- Forks
- 1.9k
- Licence
- MIT
- Language
- TypeScript
- Last update
- 5 days ago
- Type
- Library
What it is
Immutable.js is a JavaScript library that provides data structures such as List, Map, Set and Record that cannot be changed after creation. Instead of modifying data in place, operations return new updated versions, which makes application state easier to track. It is used to make code simpler and to help detect changes efficiently.
- Keep application state in a Map and update single values with set() without mutating the original
- Compare two collections for value equality with equals() or Immutable.is()
- Chain map and filter over large ranges using the lazy Seq type without building intermediate arrays
- Keep undo history by storing references to earlier versions of a collection
Great for
- JavaScript developers managing application state that is updated often
- Teams building React or Flux-style apps where data flows one way
- Developers who want cheap equality checks and memoization based on data changes
- TypeScript users who want type definitions included with the package
Not ideal for
- Projects that only need simple data and do not care about accidental mutation, since the library adds an API to learn
- Developers who need native JavaScript arrays and objects to interoperate directly without conversion, since Immutable collections are a different type
- Beginners new to JavaScript who should first learn plain objects and arrays
How to get it
- 1
Install with a package manager
You'll need: Node.js or a bundler or package manager such as npm, Yarn, pnpm, or Bun
Install using npm
npm install immutableInstall using Yarn
yarn add immutableInstall using pnpm
pnpm add immutableInstall using Bun
bun add immutable - 2
Run it
- Install the package with npm install immutable
- Import Map from 'immutable' in a module
- Create a Map with Map({ a: 1, b: 2, c: 3 })
- Call set('b', 50) to get a new map and compare it with the original using get
- 3
Get the most out of it
- Use equals() or Immutable.is() for value comparison instead of ===, as the README recommends
- Use the lazy Seq with Range and Repeat to chain collection methods efficiently
- Set the TypeScript target or lib to es2015 to use the included type definitions
- Read the full documentation at immutable-js.com/docs and the project wiki for specific topics
Downloads
Strengths
- Has no dependencies, according to the README
- Includes type definitions for Flow and TypeScript when installed via npm
- Uses structural sharing so updates reuse most of the existing data structure
Trade-offs
- Requires learning a new API and treating collections as values rather than objects
- TypeScript type definitions need ES2015 lib or target settings, per the README
- Converting between Immutable collections and plain JavaScript data adds work at boundaries
How it compares
| Project | Stars | Type | Level | Updated | Best for |
|---|---|---|---|---|---|
| immutable-js (this) | 33k | Library | intermediate | 5 days ago | JavaScript developers managing application state that is updated often |
| immer | 29k | Library | beginner | 5 days ago | JavaScript developers who find hand-written immutable updates verbose or error-prone |
Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.