Registry / storage / normalizr

normalizr

JSON →
library3.6.2jsnpmunverified

Normalizr is a library for normalizing and denormalizing JSON responses according to a schema, primarily used in Redux or Flux applications to flatten nested API data into a normalized state shape. This is version 3.6.2, the final stable release as the project is no longer maintained. It ships TypeScript type definitions and supports both ESM and CJS imports. Compared to alternatives like redux-orm or manual normalization, Normalizr offers a declarative schema-based approach without coupling to any specific state management library. It is stable but will not receive feature updates or bug fixes.

npm install normalizr
INSTALL
IMPORT
SIG · NORMALIZR
N
normalizr
storagejavascriptv3.6.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

normalize
import { normalize } from 'normalizr'
const normalize = require('normalizr').normalize
Direct named import works in both ESM and CJS. Since v3, the library is fully tree-shakable.
denormalize
import { denormalize } from 'normalizr'
import denormalize from 'normalizr'
Must use named import, not default import.
schema
import { schema } from 'normalizr'
import * as schema from 'normalizr'
The 'schema' object is a namespace containing Entity, Union, etc. Direct named import is correct.

Demonstrates normalizing a nested article object with an author and contributors into a flat entities structure, then denormalizing back.

import { normalize, denormalize, schema } from 'normalizr'; const user = new schema.Entity('users'); const article = new schema.Entity('articles', { author: user, contributors: [user] }); const inputData = { id: '1', title: 'My Article', author: { id: '1', name: 'Paul' }, contributors: [{ id: '2', name: 'Nicole' }] }; const normalized = normalize(inputData, article); console.log(normalized); // { // result: '1', // entities: { // articles: { '1': { id: '1', title: 'My Article', author: '1', contributors: ['2'] } }, // users: { '1': { id: '1', name: 'Paul' }, '2': { id: '2', name: 'Nicole' } } // } // } const denormalized = denormalize(normalized.result, article, normalized.entities); console.log(denormalized); // { id: '1', title: 'My Article', author: { id: '1', name: 'Paul' }, contributors: [{ id: '2', name: 'Nicole' }] }
Debug
Known issues
deprecatedNormalizr is no longer maintained.
fix
Consider forking the repository or migrating to an alternative library like redux-orm.
affects: >=3.6.2
gotchaWhen using denormalize, the third argument must be the complete entities object; omitting it causes runtime errors.
fix
Always pass the full entities map from normalize: denormalize(result, schema, entities).
affects: >=3.0.0
breakingVersion 3.0.0 renamed 'normalizr' to 'normalizr' (the npm package name never changed), but the API shifted from a single default export to named exports (normalize, denormalize, schema).
fix
Replace import normalizr from 'normalizr' with import { normalize } from 'normalizr'.
affects: >=3.0.0
Errors
Common errors & fixes
TypeError: Cannot read property 'entities' of undefined
Calling denormalize without the entities object as the third argument.
fix
Ensure denormalize(result, schema, entities) is called where entities is the full entities hash.
Module not found: Can't resolve 'normalizr' in '/path/to/project'
Package not installed or missing from node_modules.
fix
Run npm install normalizr or yarn add normalizr.
TypeError: schema.Entity is not a constructor
Importing the default export instead of the 'schema' named export.
fix
Use import { schema } from 'normalizr' to access the Entity constructor.
Upgrade
Version history
3.6.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
27 hits · last 30 days
node
26
Amazon
1
Resources
normalizr — npm install normalizr · libregistry