> For AI agents: the complete Sanity documentation index is available at [https://www.sanity.io/docs/llms.txt](https://www.sanity.io/docs/llms.txt).

# Schemas and forms

Schemas are the main mechanism for describing your content and how to interact with it in the Studio.

You write schemas in plain JavaScript (or TypeScript) objects that let you describe your content model in Sanity Studio. The Studio creates the forms and inputs needed to create and edit your content and stores it as structured content in [your dataset in the schema-less Content Lake database](https://www.sanity.io/docs/content-lake/datasets).

[Schema types reference](https://www.sanity.io/docs/studio/schema-types)
See all available schema types for Sanity Studio

[Schemas and the Content Operating System](https://www.sanity.io/docs/apis-and-sdks/introduction-to-schemas)
Learn how schemas work with the Sanity Content Operating System

> [!NOTE]
> A faster start with @sanity/presets
> [@sanity/presets](https://www.npmjs.com/package/@sanity/presets) is an experimental package of ready-made schema types for common content patterns (pages, links, images, SEO metadata, and rich text) that lets you skip the boilerplate and get started quickly. As it is experimental, its APIs may change.

## Anatomy of schemas

**Content model or schema**: A conceptual overview, often expressed as a diagram, of the document types in a Studio and the schema types or attributes they contain.

**Document types:** A collection of schema types used to build a standalone piece of content. Documents typically consist of multiple fields, have a revision history, can be drafted and published, and can have queryable references between them.

> [!WARNING]
> Gotcha
> *Document types can be whatever you like, and do not have to map to “a page” or “a post.”*

**Form:** The order and structure of the schema types used for a document.

**Schema types:** Catch-all for attributes used on a form to make a document and maps to `schema.types` in the config API. Sometimes we use “field types” to talk about the same concept.

### Schemas are content models

![Diagram showing that a schema is made up of document types, and document types are made up of field (schema) types.](https://cdn.sanity.io/images/3do82whm/next/d64b5188da8e1f9d53f2aefab79ac0a1160e1f62-882x372.png)

When we talk about a schema or the content model, we are referring to all the document types created for a studio. All document types are made of schema/field types. In short form:

Schema → document types → schema/field types

### Where schemas are declared

Schemas are declared in the root configuration for your Sanity Studio project, typically found in a file named `sanity.config.ts` (or `sanity.config.js` for JavaScript projects). 

**sanity.config.ts**

```typescript
import {defineConfig} from 'sanity'
import {structureTool} from 'sanity/structure'
import {schemaTypes} from './schemaTypes'

export default defineConfig({
  name: 'default',
  title: 'my-studio',

  projectId: 'YOUR_PROJECT_ID',
  dataset: 'YOUR_DATASET',

  plugins: [structureTool()],

  schema: {
    types: schemaTypes,
  },
})

```

You *can* declare your schemas inline in the configuration as an array of JavaScript objects, but the more common practice is to put your schemas in external files and import them into the `schema.types` array.

The default Studio setup when you create a new project in the CLI will include a folder at the root level called `schemaTypes` with a single file called `index.ts`. This file exports an array, which, depending on whether you started from a template or with a clean project, might be empty or might already contain some schemas.

## Example schema

Let's look at an example schema for a `person` document type. We'll add a `string` field for the name of the person and an `image` field for a portrait.

**schemaTypes/person.ts**

```typescript
export default {
  name: 'person',
  title: 'Person',
  type: 'document',
  fields: [
    {
      name: 'fullName',
      title: 'Full name',
      type: 'string',
    },
    {
      name: 'portrait',
      title: 'Portrait',
      type: 'image',
      options: {
        hotspot: true,
      }
    }
  ]
}
```

We then import our schema into our main schema file (`./schemaTypes/index.ts`) and add it to the schema array.

**schemaTypes/index.ts**

```typescript
import person from './person'

export const schemaTypes = [person]
```

The Studio will now let you create a new "Person" and provide the form inputs needed to equip your person with a name and a portrait.

![Studio screenshot showing a form with a string input for "Full name" and an image input for "Portrait"](https://cdn.sanity.io/images/3do82whm/next/dfb34aef1e43072e1a8cacd82ab35870c2df7693-800x791.png)

Your Studio comes with a range of default schema types, such as the ones we just used to create this document, and these types can be combined to create an endless number of data structures.

## Next steps

Now that you've defined a document type, learn how to shape and refine your content model with these guides.

[Validation](https://www.sanity.io/docs/studio/validation)
Add validation rules to your fields to keep content consistent.

[Conditional fields](https://www.sanity.io/docs/studio/conditional-fields)
Show, hide, or make fields read-only based on document values or user roles.



## Related changelog entries

Entries are listed newest first; each link points to the full entry as markdown. Follow one when you need to know what changed, when, or why — for example, to summarize recent updates, explain behavior that differs from older documentation, or check whether a fix has shipped.

- [@sanity/presets v1.0.0: Introducing @sanity/presets: ready-made schema types for common content patterns](https://www.sanity.io/docs/changelog/f090bd8a-c714-4044-91d5-9e693eec7cc3.md) — June 23, 2026