Sanity Pioneers: Get early access to betas, extra AI credits, and a direct line to the engineering team. Apply now

How to switch datasets in Sanity without getting errors in Studio?

4 repliesLast updated: Nov 29, 2025

hey all... how do i switch datasets? now that my schema is 99% setup i wanted to start working from an empty dataset for entering production content.
i went into
sanity.json
and set the dataset to my new one, but now i'm getting a bunch of errors in studio
AI Update

Good news - you're actually on the right track, but it sounds like you're working with an older Studio v2 setup (which used sanity.json). If you're seeing errors after changing the dataset, here's what's likely happening and how to fix it:

If you're on Studio v3 (current version)

Your dataset configuration should be in sanity.config.js (or .ts), not sanity.json. The sanity.config.js file is where all Studio configuration lives in v3. Here's what you need to do:

import { defineConfig } from 'sanity'

export default defineConfig({
  projectId: 'your-project-id',
  dataset: 'your-new-dataset-name', // Change this to your new dataset
  // ... rest of your config
})
sanity schema deploy

This is especially important if you're using newer features like Agent Actions or if you have any validation rules that depend on the schema being deployed.

If you're still on Studio v2

Studio v2 reached end-of-life in December 2023, so I'd strongly recommend migrating to v3. But if you need a quick fix for v2, check that your sanity.json has the correct dataset name under the api section.

Common errors after switching datasets

The errors you're seeing are likely because:

After updating the config and deploying the schema, restart your dev server (sanity dev or npm run dev) and the errors should clear up!

Show original thread
4 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