Browse Sanity raw data without schema in Studio

7 replies
Last updated: Apr 28, 2020
Is there a way to browse the raw data in a Sanity instance without creating a schema for it for Studio? I am working my way from a boilerplate project down to what I need, and I have some old documents referencing my documents so I can’t delete them
AI Update

Absolutely! You have several great options for browsing raw data in your Sanity instance without needing a schema defined in Studio:

Vision Tool (Built into Studio)

The easiest option is the Vision tool, which comes preinstalled with Sanity Studio. You can access it from the Studio toolbar and it lets you query your entire dataset using GROQ, regardless of whether you have schemas defined. Since it uses your authenticated Studio credentials, you'll see everything including drafts and documents without schemas.

To use it for your situation, try these queries:

// See all document types in your dataset
*[]{_type} | order(_type asc)

// Find documents referencing a specific document
*[references("your-document-id")]

// Browse all documents of a specific type
*[_type == "yourType"]

Vision is perfect for exploring your data and finding those old references before you delete documents.

groq.dev Playground

If you want to query outside of Studio, you can use groq.dev, a browser-based GROQ playground. You'll need to authenticate with your Sanity project to access your actual data. This gives you a clean interface without needing Studio running.

Sanity CLI

The Sanity CLI offers powerful data access:

# Query documents directly from terminal
sanity documents query '*[_type == "yourType"]'

# Export entire dataset as NDJSON
sanity dataset export production backup.ndjson

# List all documents
sanity documents list

The export option is particularly useful for your use case - you can export everything to a file and search through it to find those references.

HTTP API

You can also query directly via the HTTP API using curl or any HTTP client:

curl "https://YOUR-PROJECT-ID.api.sanity.io/v2021-10-21/data/query/production?query=*"

For your specific situation of finding old references before deleting documents, I'd recommend starting with Vision in Studio - it's the quickest way to run queries like *[references("doc-id")] to track down what's pointing to your documents. The references() function is specifically designed to find these cross-document relationships, which sounds exactly like what you need to clean up your dataset.

Show original thread
7 replies
Yes! For example by curling the HTTP endpoints https://www.sanity.io/docs/http-api
Is there a way to wipe all data in the instance?
There is a lot of garbage objects since I deleted most of the boilerplate schemas
The easiest way is to delete the dataset
right
There’s also this, but requires at least the sanity.json I think. Or maybe you can run it with project id and dataset name as env variables https://github.com/sanity-io/sanity-recipes/blob/master/snippets/deleteDocsByFilter.js
deleting and recreating the dataset worked, thanks!

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.

Was this answer helpful?