Sanity Attribute Limit: Do Duplicate Field Names in Different Documents Count Separately?
Let's say I have 2 documents and in each document fields are almost same but they are nested under different objects .
For Example:-
1.
Page1:{ title:'Sanity' ,subtitle:'Sanity'}Page2:{title:'Sanity' , subtitle:'Sanity'}Great question about how Sanity counts unique attribute paths! Let me clarify this for you based on the official documentation on attribute limits.
In your example with two documents:
Page1: { title: 'Sanity', subtitle: 'Sanity' }
Page2: { title: 'Sanity', subtitle: 'Sanity' }The answer is more than 3 - it would be approximately 4-6 attributes depending on the system fields.
Here's the key principle: Sanity counts unique paths, not individual field instances. According to the documentation, a path is counted based on its unique combination of attribute name and datatype. The documentation provides this example:
{
"foo": [
{
"bar": ...,
"baz": ...
},
{
"bat": {
"bar": ...
}
}
]
}This structure contains six unique paths:
foo(array)foo[](object)foo[].bar(string)foo[].baz(string)foo[].bat(object)foo[].bat.bar(string)
For your specific example:
In your two documents, you'd have:
_id(system field)_type(system field)title(your field)subtitle(your field)
Plus potentially other system fields like _createdAt, _updatedAt, etc.
The crucial point: Even though you have TWO documents with the same fields, each unique path is only counted once. Using the same field across 1 document or 1,000 documents doesn't increase your attribute count.
Important clarifications:
- Nested paths count separately: If your fields are nested under different objects (like
Page1.content.titlevsPage2.metadata.title), those ARE counted as separate paths - Only actual content counts: Just defining fields in your schema doesn't increase the count until you actually store data in those fields
- Paths are reusable: The same path used multiple times across documents only counts once
If you're hitting your 4K limit:
You can check your current attribute count at: https://<projectId>.api.sanity.io/v1/data/stats/<datasetName> (look for fields.count.value)
Common causes of hitting the limit include:
- Deeply nested structures (especially with block content)
- Field-level translations/localization (creates multiplier effect)
- Many different document types with unique fields
Consider using document-level localization instead of field-level, and arrays instead of deeply nested objects for page builders to keep your attribute count manageable.
Show original thread5 replies
Was this answer helpful?
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.