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

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

A string tag that strips indentation from multi-line strings. ⬅️

Last verified Sep 9, 2026 against dedent@1.7.2.

dedent publishes both a CommonJS entry and a native ESM entry (ESM added in 1.3.0). require("dedent") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import "dedent" works alongside it.

## What to do

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

## Facts

- Latest: 1.7.2 (Mar 1, 2026)
- Module format: Dual (CommonJS + ESM)
- Last CommonJS version: 1.7.2
- Native ESM since: 1.3.0
- TypeScript types: bundled
- Node engines: not declared
- Weekly downloads: 47.1M
- License: MIT

## Runtime test results for dedent@1.7.2

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

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

ES modules:

```js
import * as dedent from "dedent";
```

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

CommonJS:

```js
const dedent = require("dedent");
```

## Module format by version

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

| Versions | Format | First published |
|---|---|---|
| 1.3.0 – 1.7.2 | Dual (CommonJS + ESM) | Jul 27, 2023 |
| 0.1.0 – 1.2.0 | CommonJS | Jan 13, 2015 |

## Frequently asked

**Is dedent ESM-only?**

dedent@1.7.2 ships CommonJS and ESM builds. dedent publishes both a CommonJS entry and a native ESM entry (ESM added in 1.3.0). require("dedent") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import "dedent" works alongside it.

**Can I require dedent?**

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

**Does dedent work in Bun?**

Yes. import "dedent" loaded successfully in Bun 1.4.0 on Sep 9, 2026.

**Does dedent ship TypeScript types?**

Yes. dedent bundles its own type declarations; no @types package is needed.

## Links

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