
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
sanity-export
Advanced tools
One-command solution to clone public Sanity datasets with parallel asset uploads and automatic import
Truly one-command solution! Export public Sanity datasets and import them to your project with all assets and documents automatically uploaded.
⚠️ IMPORTANT: This CLI tool must be run from your target Sanity project directory (where
sanityis installed as a dependency). The tool uses the official Sanity CLI for importing, so it needs access to thesanitycommand.cd ~/your-sanity-project # Navigate to your Sanity project first npx sanity-export # Then run the tool
npx or install globallynpx sanity-export and answer promptsThe CLI must be run from your target Sanity project directory (where sanity is installed as a dependency). This ensures the sanity dataset import command works correctly.
# Navigate to your Sanity project first
cd ~/your-sanity-project
# Then run the CLI
npx sanity-export
🎯 Option 1: Interactive Mode (Recommended for Most Users)
The easiest way! Just answer the prompts:
npx sanity-export
The tool will ask for:
Then it does everything automatically! ✅
⚡ Option 2: One-Line Command (For Advanced Users/Scripts)
If you prefer command-line flags or need automation:
npx sanity-export clone \
--source-project r7m53vrk \
--target-project your-project-id \
--token sk_your_sanity_token
Both approaches do the same thing:
sanity dataset import with your credentialsNo manual steps required! The tool sets environment variables and runs the official Sanity CLI for you! 🎉
sk)npx sanity-export clone --source-project abc --target-project xyz --token sk_...
npm install -g sanity-export
sanity-export clone --source-project abc --target-project xyz --token sk_...
git clone https://github.com/ajay-develops/export-import-sanity-public-dataset-without-source-project-api-token.git
cd export-import-sanity-public-dataset-without-source-project-api-token
npm install
npm link # Makes CLI available globally
Just run without any arguments:
npx sanity-export
The tool will prompt you for:
This is the easiest way to use the tool! No need to remember flags or syntax. 🎯
clone - One-Line Complete Solution (Recommended for Automation/Scripts)For advanced users or CI/CD pipelines. Fully automated with command-line flags:
npx sanity-export clone \
--source-project r7m53vrk \
--target-project yfxnt4n8 \
--token sk_your_token
What it does automatically:
sanity dataset import automatically (sets credentials via env vars)Use this if you:
Otherwise, use interactive mode (simpler): npx sanity-export ⭐
Options:
-s, --source-project <id> - Source project ID (required)--source-dataset <name> - Source dataset (default: production)-t, --target-project <id> - Target project ID (required)--target-dataset <name> - Target dataset (default: production)-k, --token <token> - Sanity auth token (required)-o, --output <dir> - Output directory (default: current directory)-c, --concurrency <number> - Parallel uploads (default: 10, max: 15)interactive - Explicit Interactive ModeSame as running with no arguments:
npx sanity-export interactive
export - Export OnlyJust export without uploading assets:
npx sanity-export export \
--source-project r7m53vrk \
--output ./my-export
prepare-import - Prepare Existing ExportUpload assets and prepare import for an existing export:
npx sanity-export prepare-import \
--target-project yfxnt4n8 \
--token sk_your_token \
--input ./my-export
After running clone or export, you'll have:
production.tar.gz - Ready-to-import archivedata-updated.ndjson - Documents with updated asset referencesasset-id-mapping.json - Old → New asset ID mappingassets-metadata.json - Asset metadataimages/ - Downloaded image filesfiles/ - Downloaded file assets┌─────────────────────────────────────────────────────────────────┐
│ SOURCE PROJECT (Public) │
│ r7m53vrk / production │
│ 📄 Documents + 🖼️ Assets │
└────────────┬────────────────────────────────────────────────────┘
│
│ npm run export
│ (downloads via public API)
▼
┌─────────────────────────────────────────────────────────────────┐
│ LOCAL MACHINE │
│ 📁 data.ndjson (163 docs, no asset docs) │
│ 📁 assets-metadata.json (392 asset metadata) │
│ 📁 images/ (389 files) │
│ 📁 files/ (3 files) │
└────────────┬────────────────────────────────────────────────────┘
│
│ npm run prepare-import
│ (uploads assets, updates refs)
│
├──────────────────────┐
▼ ▼
┌─────────────────┐ ┌──────────────────┐
│ Upload Assets │ │ Update Refs │
│ to Target │ │ OLD → NEW IDs │
└────────┬────────┘ └────────┬─────────┘
│ │
▼ ▼
┌─────────────────────────────────────────────────────────────────┐
│ TARGET PROJECT (Yours) │
│ yfxnt4n8 / production │
│ 🖼️ 392 Assets uploaded ✅ │
└─────────────────────────────────────────────────────────────────┘
│
│ Auto-import via Sanity CLI
│ (SANITY_PROJECT_ID=yfxnt4n8 sanity dataset import)
▼
┌─────────────────────────────────────────────────────────────────┐
│ TARGET PROJECT (Complete) │
│ yfxnt4n8 / production │
│ 📄 163 Documents ✅ (auto-imported via CLI) │
│ 🖼️ 392 Assets ✅ (parallel uploaded) │
│ 🔗 All references working ✅ │
│ 🎉 Dataset ready to use! │
└─────────────────────────────────────────────────────────────────┘
If you cloned the repo locally, you can use npm scripts:
# 1. Configure .env.local
cp .env.example .env.local
nano .env.local # Add SOURCE_PROJECT_ID, TARGET_PROJECT_ID, SANITY_AUTH_TOKEN
# 2. Run export
npm run export
# 3. Prepare import
npm run prepare-import
# 4. Import
cd ~/your-sanity-project
pnpm dlx sanity dataset import ./export-import-sanity-public-dataset-without-source-project-api-token/production.tar.gz --replace
See the npm scripts section for all available commands.
⚠️ All examples should be run from your target Sanity project directory:
cd ~/your-sanity-project # Navigate to your Sanity project first!
Just run and answer the prompts:
npx sanity-export
When to use:
npx sanity-export clone \
--source-project r7m53vrk \
--target-project yfxnt4n8 \
--token sk_your_token_here
When to use:
npx sanity-export clone \
--source-project r7m53vrk \
--target-project yfxnt4n8 \
--token sk_your_token \
--output ./my-dataset-backup
npx sanity-export clone \
--source-project r7m53vrk \
--source-dataset staging \
--target-project yfxnt4n8 \
--token sk_your_token
npx sanity-export export \
--source-project r7m53vrk \
--output ./backup
npx sanity-export clone \
--source-project r7m53vrk \
--target-project yfxnt4n8 \
--token sk_token \
--concurrency 15
Performance:
--concurrency 1 - Sequential (slowest, ~20 minutes)--concurrency 5 - Conservative (safe, ~10-12 minutes)--concurrency 10 - Default (fast, ~5-8 minutes) ⭐--concurrency 15 - Maximum (fastest, ~3-5 minutes)Note: Higher concurrency = faster uploads but requires stable network. Start with default (10) and adjust based on your connection.
For local development or custom workflows:
npm run export - Export documents and assets from source projectnpm run prepare-import - ⭐ Upload assets, update references, create import packagenpm run upload-assets - Upload assets only (for manual workflows)npm run transform - Re-run transformation on existing datanpm run clean - Remove all generated filesnpm run export)production.tar.gzsanity dataset import with credentials set via environment variables:
SANITY_PROJECT_ID=your-project \
SANITY_AUTH_TOKEN=your-token \
npx sanity dataset import production.tar.gz --replace
Why this works:
Issue: "sanity: command not found" or import fails
Solution: Run the CLI from your target Sanity project directory (where sanity is installed):
# ✅ CORRECT - From your Sanity project
cd ~/your-sanity-project
npx sanity-export clone -s SOURCE -t TARGET -k TOKEN
# ❌ WRONG - From random directory
cd ~/Downloads
npx sanity-export # Will fail at import step!
The tool needs access to the Sanity CLI to run sanity dataset import.
Issue: JavaScript heap out of memory
Solution:
npx sanity-export@latest--concurrency 5 (instead of 10)node --version (18+ required)"Dataset not found"
SOURCE_PROJECT_ID in .env.local is correct"Assets fail to download"
"TARGET_PROJECT_ID is required"
.env.local has TARGET_PROJECT_ID, SANITY_AUTH_TOKEN"Upload failed with status 401"
"Upload failed with status 404"
pnpm dlx sanity dataset create productionImport succeeds but images don't show
prepare-import completed successfullycount(*[_type == "sanity.imageAsset"])export-sanity-public-dataset/
├── package.json # Dependencies and scripts
├── .env.example # Environment variable template
├── .env.local # Your configuration (git-ignored)
├── index.js # Export orchestrator
├── src/
│ ├── download-documents.js # Downloads NDJSON from Sanity
│ ├── download-assets.js # Downloads asset files
│ ├── transform-assets.js # Removes asset docs, saves metadata
│ ├── package-export.js # Creates tar.gz archive
│ ├── prepare-import.js # Uploads assets, updates refs, packages
│ └── upload-assets.js # Alternative asset upload script
└── README.md # This file
Contributions are welcome! Please feel free to submit a Pull Request.
Ideas for contributions:
To publish a new version to npm and GitHub:
# For bug fixes (1.0.0 → 1.0.1)
npm version patch && git push origin main --tags
# For new features (1.0.0 → 1.1.0)
npm version minor && git push origin main --tags
# For breaking changes (1.0.0 → 2.0.0)
npm version major && git push origin main --tags
This will:
package.jsonSee: GITHUB-ACTIONS-SETUP.md for complete setup guide
MIT
FAQs
One-command solution to clone public Sanity datasets with parallel asset uploads and automatic import
We found that sanity-export demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.