Joint session with Vercel: How to build intelligent storefronts (May 15th)

How to select and edit a specific dataset in Sanity Studio Desk?

3 repliesLast updated: Dec 1, 2025

I have a website using a production dataset with all the content already filled. I would like to create a production clone of this website but with some changes on the dataset content, no the structure. I’m currently using sanity v2, I tired creating a new data set on the same project and coping the contents from the original dataset to the new, this worked for cloning the dataset however I’m not sure how to select which dataset I want to edit when working on the Sanity Studio Desk. Any ideas? Thank you! 🙏
AI Update

Great question! For Sanity Studio v2, switching between datasets is done through configuration in your sanity.json file and environment variables. Here's how to set it up:

The cleanest approach for v2 is to use environment variables to specify which dataset your Studio should connect to. In your sanity.json, you can reference the dataset using process.env:

{
  "root": true,
  "project": {
    "name": "Your Project Name"
  },
  "api": {
    "projectId": "your-project-id",
    "dataset": "production"
  },
  "plugins": [
    "@sanity/base",
    "@sanity/desk-tool"
  ]
}

Then create .env files to switch between datasets:

For your original production dataset (.env.production):

SANITY_STUDIO_DATASET=production

For your cloned dataset (.env.staging or .env.local):

SANITY_STUDIO_DATASET=production-clone

Update your sanity.json to use the environment variable:

{
  "api": {
    "projectId": "your-project-id",
    "dataset": "${SANITY_STUDIO_DATASET}"
  }
}

Then run your Studio with the appropriate environment:

# For production dataset
sanity start

# For your cloned dataset
SANITY_STUDIO_DATASET=production-clone sanity start

# Or use a different mode
SANITY_ACTIVE_ENV=staging sanity start

Alternative: Multiple Studio Instances

Another approach is to maintain separate Studio directories or configurations for each dataset. You could:

Important Notes

Heads Up About v2

Just a friendly reminder that Sanity Studio v2 is now deprecated. When you have time, consider migrating to v3, which has a much better workspaces feature that makes switching between datasets super easy with a dropdown in the Studio UI!

For v3, you'd use workspaces configuration in sanity.config.js which gives you a native UI switcher between datasets - much more convenient than the v2 approach.

Show original thread
3 replies

Was this answer helpful?

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.

Related contributions