# Is zod-to-json-schema ESM-only? Can you require() it?

> zod-to-json-schema@3.25.2 ships CommonJS and ESM builds. Dual package — require() works on every Node.js version we test; import works too.

Converts Zod schemas to Json Schemas

Last verified Sep 9, 2026 against zod-to-json-schema@3.25.2.

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.

## Facts

- 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

## Runtime test results for zod-to-json-schema@3.25.2

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.0 | works | works |

## How to import zod-to-json-schema

ES modules:

```js
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:

```js
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") 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

- [zod-to-json-schema on npm](https://www.npmjs.com/package/zod-to-json-schema)
- [Source repository](https://github.com/StefanTerdell/zod-to-json-schema)
- [HTML version](https://canirequire.com/package/zod-to-json-schema/)
- [JSON version](https://canirequire.com/package/zod-to-json-schema.json)

---

For scripts and AI agents: any package is at https://canirequire.com/package/<name>/index.md (Markdown) or https://canirequire.com/package/<name>.json (JSON); the site index is https://canirequire.com/llms.txt. Fetch the URL directly; no search needed.
