canirequire › Dual (CommonJS + ESM) › zod-to-json-schema
Is zod-to-json-schema ESM-only? Can you require() it?
Converts Zod schemas to Json Schemas
Last verified Sep 9, 2026 against zod-to-json-schema@3.25.2. JSON
Dual (CommonJS + ESM) Dual package — both require() and import work
zod-to-json-schema publishes both a CommonJS entry and a native ESM entry (ESM added in 3.22.0). require("zod-to-json-schema") and import "zod-to-json-schema" both work on every supported Node.js version and in Bun.
Does zod-to-json-schema@3.25.2 actually load? Runtime test results
Installed and executed on Sep 9, 2026 with require("zod-to-json-schema") from a CommonJS file and import "zod-to-json-schema" from an ES module.
| Runtime | require("zod-to-json-schema") | import "zod-to-json-schema" |
|---|---|---|
| Node.js 18 | ✓ works | ✓ works |
| Node.js 20 | ✓ works | ✓ works |
| Node.js 22 | ✓ works | ✓ works |
| Node.js 24 | ✓ works | ✓ works |
| Node.js 26 | ✓ works | ✓ works |
| Bun 1.4 | ✓ works | ✓ works |
How to import zod-to-json-schema
ES modules (import)
import zodToJsonSchema from "zod-to-json-schema";CommonJS (require)
const zodToJsonSchema = require("zod-to-json-schema");Module format by version
Derived from the type, main and exports fields of every stable release on npm (81 versions; the newest 60 shown).
| Versions | Format | First published |
|---|---|---|
| 3.22.0 – 3.25.2 | Dual (CommonJS + ESM) | Nov 18, 2023 |
| 3.4.3 – 3.21.4 | CommonJS | Aug 27, 2021 |
Frequently asked
Is zod-to-json-schema ESM-only?
zod-to-json-schema@3.25.2 ships CommonJS and ESM builds. zod-to-json-schema publishes both a CommonJS entry and a native ESM entry (ESM added in 3.22.0). require("zod-to-json-schema") and import "zod-to-json-schema" both work on every supported Node.js version and in Bun.
Can I require zod-to-json-schema?
Yes. zod-to-json-schema ships a CommonJS entry, so require("zod-to-json-schema") works on every Node.js version, alongside the native ESM entry for import.
Does zod-to-json-schema work in Bun?
Yes. import "zod-to-json-schema" loaded successfully in Bun 1.4 on Sep 9, 2026.
Does zod-to-json-schema ship TypeScript types?
Yes. zod-to-json-schema bundles its own type declarations; no @types package is needed.
Links
Other dual (commonjs + esm) packages
- minimatch 10.2.6Dual
- brace-expansion 5.0.9Dual
- lru-cache 11.5.2Dual
- glob 13.0.6Dual
- eslint-visitor-keys 5.0.1Dual
- yallist 5.0.0Dual
- balanced-match 4.0.4Dual
- js-yaml 5.4.1Dual
Similar popularity
- jest 30.5.1Dual
- eslint-plugin-import 2.32.0CommonJS
- graphql 17.0.2Dual
- through 2.3.8CommonJS
- is-extendable 1.0.1CommonJS
- jest-changed-files 30.5.1Dual
- jest-circus 30.5.1Dual
- jest-resolve-dependencies 30.5.1Dual