How to solve "attribute/datatype count exceeds limit of 2000" error?
I feel your pain - hitting that 2000 attribute limit can be frustrating! This is a real constraint in Sanity's architecture, but there are several ways to address it.
Understanding the Problem
The attribute/datatype count includes every unique field path in your schema across all document types. This adds up quickly, especially with:
- Portable Text fields (each block type and annotation creates multiple paths)
- Field-level internationalization (multiplying fields by number of languages)
- Deeply nested objects and arrays
- Large schemas with many document types
Solutions to Reduce Attribute Count
1. Switch to Document-Level Localization
If you're using field-level translation (like having title.en, title.fr, etc.), this is likely your biggest culprit. As explained in Sanity's official documentation on the attribute limit, switching to document-level localization creates separate documents for each language rather than multiplying fields within a single document.
The @sanity/document-internationalization plugin makes this transition manageable. This approach dramatically reduces attribute count because you're reusing the same schema structure across language documents instead of creating unique paths for each language field.
2. Audit and Simplify Your Schema
- Remove unused fields and document types
- Flatten nested structures where possible
- Consolidate similar object types that could share a schema
- Review Portable Text customizations - custom blocks and annotations add up quickly
- Use arrays instead of deeply nested block content for page building
3. Use References Instead of Nested Objects
Instead of deeply nesting objects, consider breaking them into separate document types and using references. This can reduce the total unique paths in your schema.
4. Track Your Current Count
You can monitor your attribute usage by visiting this URL:
https://<projectId>.api.sanity.io/v1/data/stats/<datasetName>
The attribute count is in fields.count.value and the limit is in fields.count.limit.
Immediate Steps
- Export your data first using
sanity dataset export production production.tar.gzbefore making any changes - Identify the biggest contributors - internationalization plugins and Portable Text customizations are common culprits
- If using field-level i18n, migrating to document-level localization will likely solve your issue
- Clean up unused content - remove any old documents or fields that are no longer in use
- Contact Sanity support - they can help analyze your schema and suggest specific optimizations
Plan Limits
The attribute limits vary by plan:
- Standard: 2,000 attributes
- Advanced: 4,000 attributes
- Enterprise: 10,000 attributes
Note that this is currently a hard technical limit - there's no pay-as-you-go option for extra attributes.
The good news is that following these best practices typically results in a better-structured, more maintainable content model anyway! The best practices section in the docs has great examples of how to structure your content efficiently.
Show original thread8 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.