How to reduce attribute count by removing content in Sanity project?
You're not missing the point of attributes - you've actually identified a key behavior that can be confusing! Let me explain what's happening and how to fix it.
Why deleting content isn't reducing your attribute count
According to the attribute limit documentation, attributes work differently than you might expect:
Your attribute count:
- Goes up when you first add content on a path
- Goes down when a path no longer holds any content across all documents
- Stays the same regardless of whether a path is used once or many times
The key issue: Each unique path is counted once, no matter how often it's used. Removing a path from your attribute count requires deleting every piece of content on that path across all documents in your dataset - not just some documents.
So if you deleted a few documents but other documents still contain those same field paths, your attribute count won't decrease.
How to actually reduce your attribute count
Here's what you need to do:
1. Export your data first (critical!)
Before making any changes, run a full export:
sanity dataset export production production.tar.gz2. Track your progress
Monitor your attribute count using this URL:
https://<projectId>.api.sanity.io/v1/data/stats/<datasetName>
Look for fields.count.value (current count) and fields.count.limit (your limit).
3. Identify and remove unused paths
You need to remove content from paths that are no longer needed. This might include:
- Old document types that are no longer in your schema
- Deprecated fields within existing document types
- Nested structures you've refactored
The content must be removed from every document that contains those paths, including drafts (documents with drafts. prefix in their ID).
4. Consider restructuring
If you're still hitting limits, you may need to restructure your content model. Common issues that inflate attribute counts:
- Excessive nesting with block content inside custom objects
- Translation/localization that duplicates fields for each language (wrapping fields in language objects multiplies your count)
- Over-customization with too many presentational fields instead of focusing on semantic content
Check out the best practices section in the docs for detailed guidance on avoiding these pitfalls.
Hope this helps! Let me know if you need help identifying which paths are consuming your attributes.
Show original thread6 replies
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.