# @contentful/resource-names

> Helps you disassemble _Contentful Resource Names_ into its distinct parts and vice versa.

Latest version **1.12.0** (published 2026-07-28) · ISC license · 0 weekly downloads

## Install

```sh
npm install @contentful/resource-names
pnpm add @contentful/resource-names
yarn add @contentful/resource-names
bun add @contentful/resource-names
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 1.12.0 |
| Published | 2026-07-28 |
| First published | 2022-10-05 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 144.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | it-internal, whydah-gally, contentful-ecosystem, michaelpearce |

## Links

- npm: https://www.npmjs.com/package/@contentful/resource-names
- npm.io page: https://npm.io/package/@contentful/resource-names

## Recent versions

- 1.12.0 (latest) — 2026-07-28
- 1.13.0-dev-build-fed5a48.0 (dev-build-fed5a48) — 2026-09-18
- 1.12.0-dev-build-4a8805b.0 (dev-build-4a8805b) — 2026-07-28
- 1.11.0-dev-build-88fd7d7.0 (dev-build-88fd7d7) — 2026-07-12
- 1.9.2-dev-build-527f2b0.0 (dev-build-527f2b0) — 2026-06-19
- 1.9.1-dev-build-ab8565b.0 (dev-build-ab8565b) — 2026-06-09
- 1.9.0-dev-build-1428852.0 (dev-build-1428852) — 2026-06-08
- 1.9.0-dev-build-e3e48f4.0 (dev-build-e3e48f4) — 2026-06-08
- 1.8.0-dev-build-6376c37.0 (dev-build-6376c37) — 2026-05-20
- 1.7.2-dev-build-bf15411.0 (dev-build-bf15411) — 2026-05-20
- 1.7.2-dev-build-1d54fca.0 (dev-build-1d54fca) — 2026-05-20
- 1.7.1-dev-build-53546b2.0 (dev-build-53546b2) — 2026-05-19
- 1.7.1-dev-build-a8ffbef.0 (dev-build-a8ffbef) — 2026-05-19
- 1.7.0-dev-build-33c0c0c.0 (dev-build-33c0c0c) — 2026-05-18
- 1.6.3-dev-build-e8cfb15.0 (dev-build-e8cfb15) — 2025-09-04
- … 177 more at https://npm.io/package/@contentful/resource-names/versions

## README

# @contentful/resource-names

Helps you disassemble _Contentful Resource Names_ into its distinct parts and vice versa.

## Concepts

The package operates on the CRN conventions written in the [Content Management API Documentation](https://www.contentful.com/developers/docs/references/content-management-api/#/reference/references-across-spaces).

## Getting started

The package exports a set of classes that can be used to either create a CRN from its distinct parts or extract those exact same parts from a previously stringified version.

### Create a CRN class and stringify it

```typescript
import { ContentfulResourceName } from '@contentful/resource-names';

const crn = new ContentfulResourceName({
  partition: 'contentful',
  service: 'content',
  resourceId: 'spaces/a1b2c3'
});
const crnString = crn.toString();
```

### Extract individual parts

```typescript
import { ContentfulResourceName } from '@contentful/resource-names';

const { partition, service, resourceId } = ContentfulResourceName.fromString('crn:contentful:::content:spaces/a1b2c3');
```

The examples above provide a generic way to access information of a CRN, the package additionally exports tailor-made classes that will do additional work for you. We can - for example - rewrite the code from above into this:

```typescript
import { SpaceResourceName } from '@contentful/resource-names';

const spaceCrn = new SpaceResourceName({
  partition: 'contentful',
  service: 'content',
  spaceId: 'a1b2c3'
});

const { resourceId, spaceId } = SpaceResourceName.fromString('crn:contentful:::content:spaces/a1b2c3');
```

---
_Source: https://npm.io/package/@contentful/resource-names · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
