canirequire

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. Markdown · JSON

Dual (CommonJS + ESM) Dual package — require() works on every Node.js version we test; import works too

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") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import "zod-to-json-schema" works alongside it.

What to do

  1. Nothing to change. require("zod-to-json-schema") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import * as zodToJsonSchema from "zod-to-json-schema" works alongside it; use named imports for what the ESM entry exports.
  2. TypeScript: types are bundled; install nothing extra.
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.0✓ works✓ works

How to import zod-to-json-schema

ES modules (import)

import * as zodToJsonSchema from "zod-to-json-schema";

Namespace import shown because the ESM entry may have no default export; use named imports for what it exports.

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, corrected where a runtime test of that version contradicted them (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") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import "zod-to-json-schema" works alongside it.

Can I require zod-to-json-schema?

Yes. zod-to-json-schema ships a CommonJS entry alongside the native ESM entry. require("zod-to-json-schema") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun.

Does zod-to-json-schema work in Bun?

Yes. import "zod-to-json-schema" loaded successfully in Bun 1.4.0 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