# Is jwt-decode ESM-only? Can you require() it?

> jwt-decode@4.0.0 ships CommonJS and ESM builds. Dual package — require() works on every Node.js version we test; import works too.

Decode JWT tokens, mostly useful for browser applications.

Last verified Sep 9, 2026 against jwt-decode@4.0.0.

jwt-decode publishes both a CommonJS entry and a native ESM entry (ESM added in 4.0.0). require("jwt-decode") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. The package declares Node.js >=18. import "jwt-decode" works alongside it.

## What to do

1. Nothing to change. require("jwt-decode") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. The package declares Node.js >=18. import * as jwtDecode from "jwt-decode" works alongside it; use named imports for what the ESM entry exports.
2. TypeScript: types are bundled; install nothing extra.

## Facts

- Latest: 4.0.0 (Oct 27, 2023)
- Module format: Dual (CommonJS + ESM)
- Last CommonJS version: 4.0.0
- Native ESM since: 4.0.0
- TypeScript types: bundled
- Node engines: >=18
- Weekly downloads: 16.3M
- License: MIT

## Runtime test results for jwt-decode@4.0.0

Installed and executed on Sep 9, 2026 with require("jwt-decode") from a CommonJS file and import "jwt-decode" from an ES module.

| Runtime | require("jwt-decode") | import "jwt-decode" |
|---|---|---|
| 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 jwt-decode

ES modules:

```js
import * as jwtDecode from "jwt-decode";
```

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

CommonJS:

```js
const jwtDecode = require("jwt-decode");
```

## Module format by version

Derived from the type, main and exports fields of every stable release on npm (21 versions; the newest 21 shown).

| Versions | Format | First published |
|---|---|---|
| 4.0.0 | Dual (CommonJS + ESM) | Oct 27, 2023 |
| 1.0.0 – 3.1.2 | CommonJS | Feb 24, 2014 |

## Frequently asked

**Is jwt-decode ESM-only?**

jwt-decode@4.0.0 ships CommonJS and ESM builds. jwt-decode publishes both a CommonJS entry and a native ESM entry (ESM added in 4.0.0). require("jwt-decode") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. The package declares Node.js >=18. import "jwt-decode" works alongside it.

**Can I require jwt-decode?**

Yes. jwt-decode ships a CommonJS entry alongside the native ESM entry. require("jwt-decode") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. The package declares Node.js >=18.

**Does jwt-decode work in Bun?**

Yes. import "jwt-decode" loaded successfully in Bun 1.4.0 on Sep 9, 2026.

**Does jwt-decode ship TypeScript types?**

Yes. jwt-decode bundles its own type declarations; no @types package is needed.

## Links

- [jwt-decode on npm](https://www.npmjs.com/package/jwt-decode)
- [Source repository](https://github.com/auth0/jwt-decode)
- [HTML version](https://canirequire.com/package/jwt-decode/)
- [JSON version](https://canirequire.com/package/jwt-decode.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.
