npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

normalizr-modern

v1.0.0

Published

Modern, maintained fork of Normalizr - JSON normalization library with TypeScript 5.x support

Downloads

6

Readme

normalizr-modern

A modern, maintained fork of Normalizr with TypeScript 5.x support, ESM/CJS dual package output, and improved developer experience.

npm version License: MIT

What is Normalizr?

Normalizr is a library that normalizes nested JSON according to a schema. It responses to make them easier to work with.

Before:

{
 flattens API  "posts": [
    { "id": 1, "title": "Hello", "author": { "id": 1, "name": "Dan" }, "comments": [...] }
  ]
}

After:

{
  entities: {
    users: { 1: { id: 1, name: "Dan" } },
    posts: { 1: { id: 1, title: "Hello", author: 1 } },
    comments: { ... }
  },
  result: [1]
}

Installation

npm install normalizr-modern
# or
yarn add normalizr-modern
# or
pnpm add normalizr-modern

Quick Start

import { normalize, entity, array, object } from 'normalizr-modern';

// Define schemas
const user = entity({
  idAttribute: 'id'
});

const comment = entity({
  idAttribute: 'id',
  schema: {
    author: user
  }
});

const post = entity({
  idAttribute: 'id',
  schema: {
    author: user,
    comments: array({ schema: comment })
  }
});

// Normalize data
const data = {
  id: 1,
  title: 'My Post',
  author: { id: 1, name: 'Dan' },
  comments: [
    { id: 1, text: 'Great post!', author: { id: 1, name: 'Dan' } }
  ]
};

const { entities, result } = normalize(data, post);

API

normalize(input, schema)

Normalizes input data according to a schema.

const { entities, result } = normalize(apiResponse, postSchema);

denormalize(input, schema, entities)

Denormalizes normalized data back to original structure.

const original = denormalize(result, postSchema, entities);

entity(definition, options)

Creates an Entity schema for normalizing objects with IDs.

const user = entity({
  idAttribute: 'id',
  schema: {
    // nested schemas
  }
}, {
  processStrategy: (entity) => ({ ...entity, processed: true }),
  mergeStrategy: (existing, incoming) => ({ ...existing, ...incoming })
});

array(options)

Creates an Array schema for normalizing arrays.

const users = array({ schema: userSchema });
const posts = array(); // No schema - returns as-is

object(options)

Creates an Object schema for normalizing objects.

const metadata = object({
  schema: {
    settings: object(),
    tags: array()
  }
});

TypeScript

normalizr-modern is written in TypeScript 5.x with full strict mode support.

import { entity, array, normalize, Schema } from 'normalizr-modern';

interface User {
  id: number;
  name: string;
}

interface Post {
  id: number;
  title: string;
  author: User;
  comments: User[];
}

const userSchema = entity({
  idAttribute: 'id' as const
});

const postSchema = entity({
  idAttribute: 'id' as const,
  schema: {
    author: userSchema,
    comments: array({ schema: userSchema })
  }
});

// Type-safe normalization
const { result, entities } = normalize(apiData, postSchema);
// result is normalized Post, entities contains all entities

Migration from Original Normalizr

If you're migrating from the original Normalizr package:

- import { normalize, schema } from 'normalizr';
+ import { normalize, entity, array, object } from 'normalizr-modern';

- const { data, entities } = normalize(jsonResponse, [mySchema]);
+ const { result, entities } = normalize(jsonResponse, mySchema);

Key differences:

  • Import named exports instead of schema namespace
  • Use entity() instead of new schema.Entity()
  • Use array() instead of new schema.Array()
  • Use object() instead of new schema.Object()
  • normalize returns { entities, result } instead of { entities, result }

Why a Fork?

The original Normalizr was archived in March 2022. This fork provides:

  • ✅ TypeScript 5.x with strict mode
  • ✅ ESM/CJS dual package
  • ✅ Modern tooling (Vitest, es-toolkit)
  • ✅ Active maintenance
  • ✅ Better error messages
  • ✅ Improved TypeScript inference

Contributing

Contributions are welcome! Please read our Contributing Guide for details.

License

MIT License - see LICENSE for details.