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

schema-tote

v1.0.0

Published

A structured registry and loader for JSON-LD schema definitions and metadata entries

Readme

schema-tote

Canonical URL:
https://alexstevovich.com/a/schema-tote-nodejs

Software URL:
https://midnightcitylights.com/software/schema-tote-nodejs

A registry and accessor for JSON-LD schema definitions and structured metadata.
schema-tote provides a unified way to load, query, and extract schema references for websites or data-driven frameworks.


Installation

npm install schema-tote

Example

import SchemaTote from 'schema-tote';

// Initialize
const tote = new SchemaTote();

// Load a JSON file (array of wrapper entries)
tote.loadFromFile('./data/schema.json');

// 🔹 Retrieve full wrapper entries
console.log(tote.getAll()); // all entries with id, tags, and schema metadata
console.log(tote.getById('home')); // full wrapper by id
console.log(tote.getBySchemaId('https://example.com/#organization')); // wrapper by schema @id
console.log(tote.getAllBySchemaType('Organization')); // wrappers by @type
console.log(tote.getAllByType('core')); // wrappers by type
console.log(tote.getAllByTag('featured')); // wrappers by tag

// 🔹 Retrieve only the inner schema objects
console.log(tote.getSchemaById('home')); // returns just the schema node
console.log(tote.getSchemaBySchemaId('https://example.com/#organization'));
console.log(tote.getAllSchemas()); // all schemas
console.log(tote.getAllSchemasByType('Organization')); // only schemas of given @type
console.log(tote.getAllSchemasByTag('featured')); // schemas filtered by tag

// 🔹 Retrieve minimal references
console.log(tote.getRefById('home'));
console.log(tote.getRefBySchemaId('https://example.com/#person'));

/*
[
    {
        "id": "home",
        "type": "core",
        "tags": ["featured"],
        "schema": {
            "@type": "WebPage",
            "@id": "https://example.com/#home",
            "name": "Home"
        }
    },
    {
        "id": "organization",
        "type": "core",
        "tags": ["brand"],
        "schema": {
            "@type": "Organization",
            "@id": "https://example.com/#organization",
            "name": "Example Inc."
        }
    }
]
*/

// Example schema-only results:
[
    {
        '@type': 'WebPage',
        '@id': 'https://example.com/#home',
        name: 'Home',
    },
    {
        '@type': 'Organization',
        '@id': 'https://example.com/#organization',
        name: 'Example Inc.',
    },
];

Methods

loadFromFile(filePath)

Reads a .json file containing an array of schema entries and appends them to the tote.
Each entry should be a wrapper object containing { id, type, tags, schema }.

reloadFromFile(filePath)

Clears all previously loaded data and reloads from disk.


Retrieval

Retrieval methods come in two forms:

  • Wrapper getters return the full entry with metadata (id, type, tags, and schema).
  • Schema getters return only the inner JSON-LD schema object itself.

| Method | Returns | Description | | -------------------------- | ---------------- | ---------------------------------------------------------------------- | | getAll() | Array<Object> | Returns all wrapper entries. | | getById(id) | Object \| null | Returns a wrapper by its top-level id. | | getBySchemaId(schemaId) | Object \| null | Returns a wrapper by its inner schema’s @id. | | getAllBySchemaType(type) | Array<Object> | Returns all wrapper entries whose inner schema has the given @type. | | getAllByType(type) | Array<Object> | Returns all wrapper entries with the specified top-level type. | | getAllByTag(tag) | Array<Object> | Returns all wrapper entries containing a given tag (case-insensitive). |


Schema Accessors

These functions directly return only the inner schema objects
instead of their outer wrapper metadata.

| Method | Returns | Description | | ------------------------------- | ---------------- | ------------------------------------------------------------------------------------------------- | | getSchemaById(id) | Object \| null | Returns the schema object for the given top-level id. | | getSchemaBySchemaId(schemaId) | Object \| null | Returns the schema object for the given schema @id. | | getAllSchemas() | Array<Object> | Returns all inner schema objects, stripping away wrapper data. | | getAllSchemasByType(type) | Array<Object> | Returns all schema objects whose @type matches the provided type. | | getAllSchemasByTag(tag) | Array<Object> | Returns all schema objects belonging to wrappers tagged with the provided tag (case-insensitive). |


References

Reference helpers return a minimal schema reference containing only
@type and @id, suitable for lightweight linking between schemas.

| Method | Returns | Description | | ---------------------------- | ------------------------------------------ | ----------------------------------------------------------- | | getRefById(id) | {"@type": string, "@id": string} \| null | Returns a minimal reference for the schema found by id. | | getRefBySchemaId(schemaId) | {"@type": string, "@id": string} \| null | Returns a minimal reference for the schema with that @id. |

License

Licensed under the Apache License 2.0.