Discussion about exporting/importing documents between dev and production servers using Sanity.io
For a quick and dirty way to move a single document from dev to production, you've got a few options:
Quickest: Using the CLI with GROQ query
You can export a specific document by its ID and import it directly:
# Export a single document
sanity documents query --dataset development "*[_id == 'your-document-id']" > document.ndjson
# Import to production
sanity dataset import document.ndjson productionThis creates a small NDJSON file with just that document. If the document references assets (images, files), you'll need to handle those separately or use the full dataset export approach.
GUI Option: Cross Dataset Duplicator Plugin
If you prefer a point-and-click approach, install the Cross Dataset Duplicator plugin:
npm i @sanity/cross-dataset-duplicatorThis lets content editors copy documents between datasets directly from the Studio interface without touching the command line. It handles both documents and their associated assets.
Full Dataset Export (overkill but reliable)
If you need everything including assets, you can use the dataset export command:
# Export from dev
sanity dataset export development dev.tar.gz
# Import to production (merges with existing content)
sanity dataset import dev.tar.gz productionThis exports the entire dataset, so it's overkill for a single document, but it's the most reliable way to ensure all assets and references come along.
Important notes:
- Imports merge with existing content by default - they won't overwrite your production dataset
- The schema definition lives in your code, not in the export, so make sure your production schema supports the document type you're moving
- If the document has references to other documents, those referenced documents won't be included unless you export them too
For a truly quick one-off, I'd go with the GROQ query approach. For something you'll do regularly, the Cross Dataset Duplicator plugin is worth setting up.
Sanity – Build the way you think, not the way your CMS thinks
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.