Socket
Book a DemoInstallSign in
Socket

zod-package-json

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zod-package-json

Zod schema for the package.json file format

2.1.0
latest
Source
npmnpm
Version published
Weekly downloads
47K
-11.36%
Maintainers
1
Weekly downloads
 
Created
Source

zod-package-json

Build status Coverage jsDocs.io Language npm License

Zod 4 schema for the package.json file format.

This package exports a Zod and a Zod mini schema (and the inferred TypeScript type) named PackageJson that can parse most well-formed package.json files.

The schema includes all currently supported properties listed in the npm docs as well as additional well-known properties specific to TypeScript and Node.js.

The schema also preserves unknown properties, which can be accessed by indexing the parsed data with the desired string keys.

The schema only validates the known properties against their expected type but does not do any additional normalization such as merging similar properties. If necessary, that can be done by extending the schema with Zod methods such as .transform() or .refine().

Useful resources

Install

[!NOTE]
Make sure you have Zod v4 installed in your application to use this package.

Using npm:

npm add zod zod-package-json

Using yarn:

yarn add zod zod-package-json

Using pnpm:

pnpm add zod zod-package-json

Using bun:

bun add zod zod-package-json

Usage examples

To use the classic Zod schema:

import { PackageJson } from "zod-package-json";

// Parse data from a `package.json` file.
const packageJson = PackageJson.parse({
	name: "foo",
	version: "1.0.0",
	unknownProp: "who knows",
});

// Access a known property.
packageJson.name; // "foo"

// Access an unknown property.
packageJson["unknownProp"]; // "who knows"

To use the Zod mini schema:

import { PackageJson } from "zod-package-json/mini";

// Parse data from a `package.json` file.
const packageJson = PackageJson.parse({
	name: "foo",
	version: "1.0.0",
	unknownProp: "who knows",
});

// Access a known property.
packageJson.name; // "foo"

// Access an unknown property.
packageJson["unknownProp"]; // "who knows"

License

MIT

Copyright (c) 2025 Edoardo Scibona

See LICENSE file.

Keywords

zod

FAQs

Package last updated on 26 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.