How AI is powering better personalization in e-commerce [with Vercel]. Sign up now

Import external JSON for Sanity schema list options

23 repliesLast updated: Nov 29, 2025

Hello, hope everyone is having a nice day!
I’ve got a schema set up for an array of strings, and I’d like to use a list to create checkboxes for entry. Is it possible to import an external JSON file to define the options for the list rather than listing them in my schema file?

bkgd: I’m using 11ty for my front end and have the options defined in a _data file that I want to use for Sanity so the list is in one place only!
AI Update

Good news – yes, you can absolutely import an external JSON file to define options for your schema! This is a common pattern and keeps your configuration DRY.

Since your schema files are just JavaScript/TypeScript modules, you can import JSON files directly at the top of your schema file and use that data to populate the options.list property. Here's how:

1. Import your JSON file:

import { defineField, defineType } from 'sanity'
import myOptions from '../path/to/your-11ty-data-file.json'

2. Use it in your schema:

export default defineType({
  name: 'myDocument',
  type: 'document',
  fields: [
    defineField({
      name: 'tags',
      type: 'array',
      of: [{ type: 'string' }],
      options: {
        layout: 'checkbox',
        list: myOptions.map(option => ({
          title: option.label, // or whatever your JSON structure uses
          value: option.value
        }))
      }
    })
  ]
})

Important notes:

For the checkbox layout specifically, set layout: 'checkbox' in the options (as shown above). This works great for arrays of strings where you want multiple selections displayed as checkboxes rather than a dropdown or tags input.

This approach keeps your options in one place (your 11ty _data file), and both your frontend and Sanity Studio will reference the same source of truth. Just remember that if you update the JSON file, you'll need to restart your Studio dev server to see the changes reflected.

There's a Sanity Answers thread that discusses this exact use case if you want to see more examples!

Show original thread
23 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