
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeOof, that's frustrating when the desk crashes and you can't even access the document to delete it! I've been there. Here are a few ways to handle this:
If you can see the document in your Studio's list view (even if clicking it crashes), you can usually hover over or right-click it to see the document ID in the URL or browser status bar. The ID will look something like drafts.abc123-def4-5678-90gh-ijklmnopqrst.
Alternatively, you can use the CLI to query for documents:
sanity documents query "*[_type == 'yourDocumentType']._id"This will list all document IDs of that type. You can add more filters to narrow it down if needed.
Once you have the ID, you can delete it directly from the CLI:
sanity documents delete YOUR-DOCUMENT-IDIf you need to delete multiple problematic documents, there's a helpful guide on bulk deletion using the CLI. For example, to delete all documents of a specific type:
sanity documents query "*[_type == 'problematicType'][0...20]._id" --apiVersion 2021-03-25 \
| groq "*" -o ndjson \
| xargs sanity documents deleteNote: The guide limits this to 20 documents at a time to avoid timeouts. You can run it multiple times if needed.
Before making schema changes, it's a good idea to export your dataset as a backup:
sanity dataset export production backup.tar.gzThis way, if something goes wrong with a schema change, you can investigate the data structure or restore if needed. The schema migration docs also have some good practices for handling schema changes safely.
Hope this gets you unstuck! Let me know if the document delete command gives you any trouble.
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.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store