canirequire

canirequireDual (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.

Latest
3.25.2 (Mar 27, 2026)
Module format
Dual (CommonJS + ESM)
Last CommonJS version
3.25.2
Native ESM since
3.22.0
TypeScript types
Bundled
Node engines
not declared
Weekly downloads
41.9M
License
ISC

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.

Runtimerequire("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).

VersionsFormatFirst published
3.22.0 – 3.25.2Dual (CommonJS + ESM)Nov 18, 2023
3.4.3 – 3.21.4CommonJSAug 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

Similar popularity