A CLI tool for copying Shopify Metafield and Metaobject definitions from one Shopify store to another. This tool is primarily designed for transferring configurations from development stores to production stores.
npm install -g shopify-metadata-migratorThis tool allows you to copy:
- Metafield Definitions: Custom field definitions for various Shopify objects (products, variants, collections, etc.)
- Metaobject Definitions: Custom object type definitions with their field structures
- Node.js 18+ (required for native fetch support)
- Access to both source and target Shopify stores
- Admin API access tokens for both stores
npm install -g shopify-metadata-migratornpm install shopify-metadata-migrator
npx shopify-metadata-migrator --help# Clone or download this repository
git clone https://github.com/warriorachilles/shopify-metadata-migrator.git
cd shopify-metadata-migrator
# Ensure you have Node.js 18+ installed
# No additional dependencies required (uses native Node.js fetch)
node migrateShopifyMetafields.js --helpshopify-metadata-migrator --sourceStore <source-store> --sourceToken <source-token> --targetStore <target-store> --targetToken <target-token> --metafields --metaobjects --shopifyObjectTypes <object-types>| Parameter | Required | Description |
|---|---|---|
--sourceStore |
Yes | Source Shopify store domain (e.g., my-dev-store) |
--sourceToken |
Yes | Source Shopify admin API access token |
--targetStore |
Yes | Target Shopify store domain (e.g., my-prod-store) |
--targetToken |
Yes | Target Shopify admin API access token |
--metafields |
No | Flag to copy metafield definitions |
--metaobjects |
No | Flag to copy metaobject definitions |
--shopifyObjectTypes |
Yes | Comma-separated list of Shopify object types for metafields |
--apiVersion |
No | Shopify API version to use (default: 2025-07) |
shopify-metadata-migrator \
--sourceStore my-dev-store \
--sourceToken shpat_xxxxxxxxxxxxxxxxxxxx \
--targetStore my-prod-store \
--targetToken shpat_yyyyyyyyyyyyyyyyyyyy \
--metafields \
--metaobjects \
--shopifyObjectTypes PRODUCT,PRODUCTVARIANT,COLLECTIONshopify-metadata-migrator \
--sourceStore my-dev-store \
--sourceToken shpat_xxxxxxxxxxxxxxxxxxxx \
--targetStore my-prod-store \
--targetToken shpat_yyyyyyyyyyyyyyyyyyyy \
--metafields \
--shopifyObjectTypes PRODUCT,COLLECTIONshopify-metadata-migrator \
--sourceStore my-dev-store \
--sourceToken shpat_xxxxxxxxxxxxxxxxxxxx \
--targetStore my-prod-store \
--targetToken shpat_yyyyyyyyyyyyyyyyyyyy \
--metaobjects \
--shopifyObjectTypes PRODUCTshopify-metadata-migrator \
--sourceStore my-dev-store \
--sourceToken shpat_xxxxxxxxxxxxxxxxxxxx \
--targetStore my-prod-store \
--targetToken shpat_yyyyyyyyyyyyyyyyyyyy \
--metafields \
--metaobjects \
--shopifyObjectTypes PRODUCT,COLLECTIONshopify-metadata-migrator \
--sourceStore my-dev-store \
--sourceToken shpat_xxxxxxxxxxxxxxxxxxxx \
--targetStore my-prod-store \
--targetToken shpat_yyyyyyyyyyyyyyyyyyyy \
--metafields \
--metaobjects \
--shopifyObjectTypes PRODUCT,COLLECTION \
--apiVersion 2025-01The --shopifyObjectTypes parameter accepts comma-separated values. Common types include:
PRODUCTPRODUCTVARIANTCOLLECTIONCUSTOMERORDERPAGEBLOGARTICLE
For a complete list of supported types, see the Shopify Admin API documentation.
- Metaobject References: The tool cannot copy metaobject definitions that contain fields with metaobject references (
metaobject_referencetype) - Metafield Metaobject References: The tool cannot copy metafields that are references to metaobjects
- API Complexity: Creating these reference types programmatically requires specific metaobject IDs, which makes automated copying challenging
- Metaobject definitions with fields that reference other metaobjects
- Metafield definitions that reference metaobjects
- Any definitions that would cause API errors during creation
The tool uses Shopify's Admin GraphQL API and supports version management:
- Default Version: Uses
2025-07by default - Manual Override: Use
--apiVersionparameter to specify a different version - Version Compatibility: Ensure both source and target stores support the specified API version
- Future-Proofing: When Shopify deprecates older API versions, you can easily switch to newer versions
- Use Default: The tool uses 2025-07 by default, which is a stable and recent version
- Manual Override: Use
--apiVersionwhen you need a specific version - Test First: Test with a development store before using in production
- Monitor Deprecation: Follow Shopify's API deprecation schedule
- Source Data Retrieval: Fetches metafield and metaobject definitions from the source store using Shopify's Admin GraphQL API
- Data Transformation: Processes the definitions to remove internal IDs and flatten nested structures
- Validation: Checks for unsupported reference types and skips problematic definitions
- Target Creation: Creates the definitions in the target store using the Admin GraphQL API
- Error Handling: Reports any creation failures with detailed error messages
The tool provides detailed error reporting:
- GraphQL errors are logged with full details
- Failed definition creations show specific user errors
- Original variables are logged for debugging purposes
- Store your access tokens securely
- Use environment variables for tokens in production environments
- Ensure tokens have appropriate permissions (read access to source, write access to target)
- Consider using private apps with limited scopes
- "GraphQL query failed": Check your access tokens and store domains
- "User Errors": Review the specific error messages for validation issues
- Missing definitions: Some definitions may be skipped due to reference limitations
The tool provides verbose logging by default. Look for:
************ CREATING METAOBJECT DEFINITION FOR [name] ************************************* CREATING METAFIELD DEFINITION FOR [name] *************************- Success/failure messages for each definition
This tool was created by Zion Emond. Feel free to submit issues or improvements.
This package is automatically published to npm when:
- A new GitHub release is created (automated)
- The manual publish workflow is triggered (manual)
To publish manually:
- Go to the Actions tab
- Select "Manual Publish to npm"
- Enter the new version number
- Click "Run workflow"
To test the package locally before publishing:
npm link
shopify-metadata-migrator --helpThis project uses ESLint and Prettier for code quality and formatting:
Linting (ESLint)
# Check for linting issues
npm run lint
# Fix auto-fixable linting issues
npm run lint:fixFormatting (Prettier)
# Format all files
npm run format
# Check if files are properly formatted
npm run format:checkDevelopment Workflow
# Install dependencies
npm install
# Run linting and formatting checks
npm run lint
npm run format:check
# Fix issues automatically
npm run lint:fix
npm run formatThis project is licensed under the MIT License - see the LICENSE file for details.
Please ensure compliance with Shopify's API terms of service when using this tool.
For issues related to:
- Shopify API: Refer to Shopify's API documentation
- Tool functionality: Check the error messages and ensure you're using Node.js 18+
- Access tokens: Verify permissions in your Shopify admin panel
