Import Content into Contentstack

Once you have exported content using one of the exporting utility tools, the next step is to import this data into Contentstack. If you have used any other exporting tool (other than Contentstack’s import utility), refer to this guide to understand how to restructure your data in the format that Contentstack’s import utility will understand. Once you restructure the data (or if you have used Contentstack’s export tool), refer to the steps given below to import content into Contentstack.

Download the utility

To import your content to Contentstack, you need to first download the 'contentstack-import' utility tool from GitHub. This utility tool consists of modules that will help you import your content saved in JSON format in your file system.

In order to import data into Contentstack, it is imperative to have converted your content into JSON format. This makes it easier to import data into Contentstack.

Install Node modules

Node.js modules play an essential part in the effective working of the import utility tool. Using Node.js package manager (npm), the essential modules of the utility tool will be extracted into your file system.

Navigate to the root folder of the utility tool and run the command given below to install the node modules that are necessary for executing the utility tool:

npm install

Add configuration details

Before importing the content, certain changes need to be made in the configuration file of the utility tool. So, open the 'index.json' file within the 'config' folder of the utility tool and add the following configuration details:

"base_locale":{"name": <<YOUR MASTER LOCALE NAME>>,
"password" : <<PASSWORD>>
"source_stack" : <<SOURCE_STACK_API_KEY>>
"target_stack" : <<TARGET_STACK_API_KEY>>

You need to provide the locale name and code of the stack, your Contentstack registered email and password, the API key of the source stack and the destination stack, and finally, provide the path of the location in your file system where the data you intend to migrate is stored.

Note: You need to be careful when providing the 'base_locale' value, because if it differs to the master locale of the stack, the migration procedure fails.

Import modules

After entering the configuration details, you are now ready to import content into Contentstack. Content will be imported into Contentstack only if it is saved in the JSON format.

On the basis of your requirement, you can either perform a complete import of your content or you can import specific modules.

  1. To import the entire content, run the command given below:
    npm run import
    This command will import data from the content that is exported and stored in our local system. These files are imported from the path mentioned in the 'data' key in the 'index.js' file under the 'config' folder.
  2. To import specific modules, run the command given below:
    npm run import {module-name}
    When importing modules individually, make sure you follow the module sequence as given below, for example, before importing entries, you must have had imported assets, environments, locales, and content types:
    • assets
    • environments
    • locales
    • contentTypes
    • entries

Note: This utility tool can be used to import only the latest published version of an entry.

Was this article helpful?