Registry / devops / contentful-to-sanity

contentful-to-sanity

JSON →
library5.0.0jsnpmunverified

A CLI tool for migrating Contentful spaces to Sanity CMS. Current stable version is 5.0.0. It generates Sanity schemas, types, and prepares dataset NDJSON files for import. Supports Contentful management tokens and access tokens. Requires Node >=20. Ships TypeScript types. Differentiates from manual migration by automating schema generation and dataset preparation.

npm install contentful-to-sanity
INSTALL
IMPORT
SIG · CONTENTFUL-TO-SANI
C
contentful-to-sanity
devopsjavascriptv5.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Command
import { Command } from 'contentful-to-sanity/command'
const Command = require('contentful-to-sanity').Command
ESM-only; subpath exports require full path.
runMigration
import { runMigration } from 'contentful-to-sanity'
import runMigration from 'contentful-to-sanity'
Named export, not default.
types
import type { Config } from 'contentful-to-sanity'
import { Config } from 'contentful-to-sanity'
Use 'import type' for type-only imports when using TypeScript.

Migrate a Contentful space to a locally prepared Sanity project.

npx contentful-to-sanity@latest -s YOUR_SPACE_ID -t YOUR_MANAGEMENT_TOKEN -a YOUR_ACCESS_TOKEN ./migrate
Debug
Known issues
breakingNode.js version must be >=20. Older versions will fail with syntax errors.
fix
Upgrade Node.js to v20 or later.
affects: <20
deprecatedSanity v2 projects are not supported. Only Sanity v3 and later.
fix
Use Sanity CLI v3 when creating the destination project.
affects: >=5.0.0
gotchaThe management token must be a personal access token, not a Content Delivery API key.
fix
Generate a personal token in Contentful Settings → API keys → Content management tokens.
affects: >=5.0.0
gotchaMigration produces a dataset.ndjson file; waiting for import is optional before Studio usage.
fix
The Studio will reflect import progress in real-time.
affects: >=5.0.0
gotchaSchema types are generated in ./schema.ts, not ./schemas. Manual import path update required.
fix
Replace 'import {schemaTypes} from ./schemas' with 'import {types as schemaTypes} from ./schema' in sanity.config.ts.
affects: >=5.0.0
Errors
Common errors & fixes
Error: Cannot find module 'contentful-to-sanity'
Global install not using npx, or missing node_modules.
fix
Use npx contentful-to-sanity@latest or npm install -g contentful-to-sanity.
Error: Command requires arguments: -s, -t, -a
Missing required flags.
fix
Run with all required flags: npx contentful-to-sanity@latest -s <space-id> -t <management-token> -a <access-token> ./migrate
Error: Invalid or expired content management token
Token may be expired or not a personal access token.
fix
Generate a new personal token in Contentful and use with -t flag.
SyntaxError: Unexpected token '??'
Running on Node.js <20.
fix
Upgrade Node.js to v20 or later.
Upgrade
Version history
5.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Amazon
1
Resources
contentful-to-sanity — npm install contentful-to-sanity · libregistry