This Friday: Hear from Sanity + Vercel experts on AI and better personalization in e-commerce →

Define empty/placeholder object in schema array as identifier

6 repliesLast updated: Nov 29, 2025

Hi all đź‘‹
I wonder if it’s possible to define an empty or placeholder object within schema array? Something that could just act as an identifier within content blocks.
AI Update

Yes, you can definitely create an empty or placeholder object within a schema array! This is useful for identifiers, dividers, or markers within content blocks.

Here's how you can define a minimal object type in your array:

{
  name: 'contentBlocks',
  type: 'array',
  of: [
    {
      type: 'block' // regular content
    },
    {
      name: 'placeholder',
      type: 'object',
      fields: [
        {
          name: 'identifier',
          type: 'string',
          title: 'Identifier',
          initialValue: 'marker'
        }
      ],
      preview: {
        select: {
          identifier: 'identifier'
        },
        prepare({identifier}) {
          return {
            title: `--- ${identifier || 'Placeholder'} ---`
          }
        }
      }
    }
  ]
}

If you want an even more minimal placeholder that's truly "empty" (no fields at all), you can do:

{
  name: 'divider',
  type: 'object',
  fields: [
    {
      name: 'hidden',
      type: 'string',
      hidden: true,
      initialValue: 'divider'
    }
  ],
  preview: {
    prepare() {
      return {
        title: '--- Divider ---',
        subtitle: 'Visual separator'
      }
    }
  }
}

The key points:

This approach works great for creating visual separators, section markers, or any kind of structural identifier in your content blocks. The array fields documentation explains how arrays support multiple member types and how each item gets tracked with unique keys.

Show original thread
6 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.

Related contributions