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

@antinna/schema-ld-types

v1.0.0

Published

TypeSafe library for Schema.org JSON-LD with validation and serialization.

Readme

@antinna/schema-ld-types

npm version license npm downloads Sponsor

A comprehensive, typesafe library for Schema.org JSON-LD objects. Ensure runtime and compile-time accuracy for your structured search data, metadata serialization, and dynamic JSON-LD injection.


Features

  • Full Type-Safety: Autogenerated TypeScript definitions directly compiled from the Schema.org vocabulary.
  • Validation & Typeguards: Helper utilities to validate and assert schema structures.
  • Hydration: Automatically insert missing @type properties onto nested objects.
  • Serialization/Deserialization: Seamless translation to and from JSON-LD strings with automatically resolved @context.

Installation

npm install @antinna/schema-ld-types

Usage Examples

Here are some standard ways to validate, serialize, deserialize, and check types for Schema.org JSON-LD elements.

1. Import Types & Utilities

import { 
  Person, 
  validate, 
  assertType, 
  serialize, 
  deserialize, 
  hydrate 
} from '@antinna/schema-ld-types';

2. Validate Data (Type Guarding)

Ensure at runtime that an object conforms to the expected Schema.org hierarchy.

const data: any = {
  '@type': 'Person',
  name: 'Jane Doe',
  jobTitle: 'Software Engineer',
  worksFor: {
    '@type': 'Organization',
    name: 'Antinna'
  }
};

if (validate<Person>(data, 'Person')) {
  // TypeScript now knows 'data' is Person
  console.log(`Successfully verified Person: ${data.name}`);
} else {
  console.error("Invalid Person structure!");
}

3. Assertion Testing

Throws an error if the object does not conform to the expected type.

try {
  const verifiedPerson = assertType<Person>(data, 'Person');
  console.log(verifiedPerson.name);
} catch (error) {
  console.error(error.message);
}

4. Serialize to JSON-LD String

Automatically prepends the correct @context to your structured data.

const author: Person = {
  '@type': 'Person',
  name: 'Manish',
  url: 'https://github.com/manishmg3994'
};

const jsonLdString = serialize(author);
console.log(jsonLdString);
/* 
Output:
{
  "@context": "https://schema.org",
  "@type": "Person",
  "name": "Manish",
  "url": "https://github.com/manishmg3994"
}
*/

5. Deserialize & Hydrate

Parses a JSON-LD string and automatically hydrates missing nested @type properties recursively based on Schema.org rules.

const rawJson = `
{
  "name": "John Doe",
  "worksFor": {
    "name": "Antinna"
  }
}
`;

// Deserializes and automatically infers worksFor's @type as Organization
const loadedPerson = deserialize<Person>(rawJson, 'Person');

console.log(loadedPerson['@type']); // "Person"
console.log(loadedPerson.worksFor['@type']); // "Organization"

Funding and Sponsorship

If you find this library useful, please consider supporting the project and its development!

💖 Sponsor on GitHub Sponsors


License

This project is licensed under the MIT License.