CLI reference

Schemas CLI command reference

List, validate, extract, and deploy schema.

Available commands

npx sanity schemas --help

Commands

delete

USAGE
  $ sanity schemas delete [-d <name>] [-p <id>] [--yes] --ids <value> [--verbose]

FLAGS
  -d, --dataset=<name>  Delete schemas from a specific dataset
  -y, --yes             Delete schemas without prompting for confirmation
      --ids=<value>     Comma-separated list of schema ids to delete
      --verbose         Enable verbose logging

OVERRIDE FLAGS
  -p, --project=<id>  Project ID to delete schema from (overrides CLI configuration)

DESCRIPTION
  Delete schema documents by id

EXAMPLES
  Delete a single schema

    $ sanity schemas delete --ids sanity.workspace.schema.workspaceName

  Delete multiple schemas

    $ sanity schemas delete --ids sanity.workspace.schema.workspaceName,prefix.sanity.workspace.schema.otherWorkspace

deploy

USAGE
  $ sanity schemas deploy [--extract-manifest] [--manifest-dir <directory>] [--tag <tag>] [--verbose] [--workspace <name>]

FLAGS
      --extract-manifest          Regenerate manifest before deploying (use --no-extract-manifest to skip)
      --manifest-dir=<directory>  Directory containing manifest file
      --tag=<tag>                 Add a tag suffix to the schema id
      --verbose                   Print detailed information during deployment
      --workspace=<name>          The name of the workspace to deploy a schema for

DESCRIPTION
  Deploy schema documents into workspace datasets.
  
  Note: This command is experimental and subject to change.
  
  Regenerates a manifest file by default. To re-use an existing manifest, use --no-extract-manifest.

EXAMPLES
  Deploy all workspace schemas

    $ sanity schemas deploy

  Deploy the schema for only the workspace "default"

    $ sanity schemas deploy --workspace default

extract

USAGE
  $ sanity schemas extract [--config-path <path>] [--enforce-required-fields] [--force] [--format <format>] [--path <value>] [--watch] [--watch-patterns <glob>] [--workspace <name>]

FLAGS
      --config-path=<path>       Path to the Sanity Studio config file
      --enforce-required-fields  Makes the schema generated treat fields marked as required as non-optional
      --force                    Overwrite an existing schema file
      --format=<format>          Output format (currently only groq-type-nodes)
      --path=<value>             Optional path to specify destination of the schema file
      --watch                    Enable watch mode to re-extract schema on file changes
      --watch-patterns=<glob>    Additional glob pattern(s) to watch (can be specified multiple times)
      --workspace=<name>         The name of the workspace to generate a schema for

DESCRIPTION
  Extract a JSON representation of a Sanity schema within a Studio context.
  
  Note: This command is experimental and subject to change.

EXAMPLES
  Extracts schema types in a Sanity project with more than one workspace

    $ sanity schemas extract --workspace default

  Watch mode - re-extract on changes

    $ sanity schemas extract --watch

  Watch with custom glob patterns

    $ sanity schemas extract --watch --watch-patterns "lib/**/*.ts"

list

USAGE
  $ sanity schemas list [--id <schema_id>] [--json]

FLAGS
      --id=<schema_id>  Fetch a single schema by id

GLOBAL FLAGS
      --json  Format output as json.

DESCRIPTION
  List all schemas in the current dataset.
  
  Note: This command is experimental and subject to change.
  
  Regenerates a manifest file by default. To reuse an existing manifest, use --no-extract-manifest.

EXAMPLES
  List all schemas found in any workspace dataset in a table

    $ sanity schemas list

  Get a schema for a given id

    $ sanity schemas list --id _.schemas.workspaceName

  Get stored schemas as pretty-printed json-array

    $ sanity schemas list --json

  Get singular stored schema as pretty-printed json-object

    $ sanity schemas list --json --id _.schemas.workspaceName

validate

USAGE
  $ sanity schemas validate [--debug-metafile-path <value>] [--format <value>] [--level <value>] [--workspace <value>]

FLAGS
      --format=<value>     The output format used to print schema errors and warnings
      --level=<value>      The minimum level reported out
      --workspace=<value>  The name of the workspace to use when validating all schema types

DEBUG FLAGS
      --debug-metafile-path=<value>  Optional path where a metafile will be written for build analysis. Only written on successful validation. Can be analyzed at https://esbuild.github.io/analyze/

DESCRIPTION
  Validates all schema types specified in a workspace

EXAMPLES
  Validates all schema types in a Sanity project with more than one workspace

    $ sanity schemas validate --workspace default

  Save the results of the report into a file

    $ sanity schemas validate > report.txt

  Report out only errors

    $ sanity schemas validate --level error

  Generate a report which can be analyzed with https://esbuild.github.io/analyze/

    $ sanity schemas validate --debug-metafile-path metafile.json

Was this page helpful?

Sanity logosanity.ioAll Systems Operational© Sanity 2026
Change site theme