
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
zod-package-json
Advanced tools
Zod schema for the package.json
file format.
This package exports a zod schema (and a 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 listed properties against the 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()
.
Using npm
:
npm add zod-package-json
Using yarn
:
yarn add zod-package-json
Using pnpm
:
pnpm add zod-package-json
Using bun
:
bun add zod-package-json
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"
MIT
Copyright (c) 2025 Edoardo Scibona
See LICENSE file.
FAQs
Zod schema for the package.json file format
The npm package zod-package-json receives a total of 36,101 weekly downloads. As such, zod-package-json popularity was classified as popular.
We found that zod-package-json demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.