Deleting a schema in Sanity does not delete related documents, but they can be deleted in batch using the CLI. The discussion also provides an explanation of how Sanity's...
No, removing a schema in Sanity does not automatically delete related documents.
This is actually a deliberate design choice that Sanity considers a feature. When you remove or change a schema type in your Sanity Studio configuration, the existing documents in your Content Lake remain untouched. This helps prevent unintended data loss and gives you full control over how to handle existing content.
Why this matters
Sanity treats schema changes similar to how databases handle data model changes - they should be intentional, reproducible, and part of your development workflow. Your content model and your actual data are kept separate, so removing a document type from your schema won't cascade into deleting the actual documents.
What happens to "orphaned" documents
When you remove a schema type:
- Documents with that
_typestill exist in your dataset - They just won't be accessible through Studio anymore (since there's no schema to render them)
- They'll still show up in API queries
- The
sanity documents validateCLI command will report them as documents with a_typenot covered in your schema configuration
How to handle documents after removing a schema
You have several options:
Keep them - If you might need the data later, just leave them. They don't hurt anything.
Delete them manually - Use the HTTP API or write a script to delete documents of that type.
Migrate them - Use content migrations to transform them into a different document type or structure.
Mark as deprecated - Before removing a schema, you can mark it as
deprecatedwith a reason, which will show warnings in Studio but keep everything accessible.
This separation between schema and data gives you flexibility to evolve your content model without risking accidental data loss.
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.