Import and Export data with contentful-cli

March 3, 2020

Import and Export contentful data with below steps.

Step 1: installation

Local installation Using npm:

npm install -g contentful-cli

step-1.1

Step 2: contentful-cli

Type below command and you gonna see details as per below screenshot:

contentful

step-2.1

Step 3: login in contentful-cli

Type below command for login in contentful-cli

contentful login

step-3.1

Now login with the browser. Copy to clipboard and paste into the command line.

step-3.2

Now you have a successful login.

step-3.3

Step 4: space list

Now time to export the data from contentful so let's start.

you can see all the space list with below command

contentful space list

step-4.1

Now you can choose specific space which data you want to export or import. with below command

contentful space use

step-4.2

choose any one space

Step: 5 Export Data

After selecting space now type below command to export data

contentful space export

step-5.1

Now you can see contentful-cli generated some random name contentful-export.json files in the root directory with all Exported entities.

Yeah, its to easy right...

Step 6: Import Data

for importing your JSON file into contentful-cms you have to put contentful-data.json file in root directress with any name. for now, I have created contentful-data.json in the root so let's start.

before start importing the contentful-data.json data you have to first take a look in which space you want to import data with below command. you can change space from here also.

contentful space use

Import data contentful-data.json ( Local file ) to contentful with below command

contentful space import --content-file contentful-data.json

step-6.1

Step 7: Finish

Now you can check your contentful space and all the data which we have imported from JSON files.

If you want to learn more about contentful-cli check it out below link:

Share: