Unlock seamless workflows and faster delivery with our latest releases – get the details

Schema

Validate all schema types in a workspace

Available commands

usage: sanity schema [--default] [-v|--version] [-d|--debug] [-h|--help] <command> [<args>]

Commands:
   extract   Extracts a JSON representation of a Sanity schema within a Studio context.
   validate  Validates all schema types specified in a workspace.

See 'sanity help schema <command>' for specific information on a subcommand.

Extract a schema

usage: sanity schema extract

   Extracts a JSON representation of a Sanity schema within a Studio context.

**Note**: This command is experimental and subject to change.

Options
  --workspace <name> The name of the workspace to generate a schema for
  --path Optional path to specify destination of the schema file
  --enforce-required-fields Makes the schema generated treat fields marked as required as non-optional. Defaults to false.
  --format=[groq-type-nodes] Format the schema as GROQ type nodes. Only available format at the moment.

Examples
  # Extracts schema types in a Sanity project with more than one workspace
  sanity schema extract --workspace default

Validate a schema

usage: sanity schema validate

  Validates all schema types specified in a workspace.

Options
  --workspace <name> The name of the workspace to use when validating all schema types.
  --format <pretty|ndjson|json> The output format used to print schema errors and warnings.
  --level <error|warning> The minimum level reported out. Defaults to warning.

Examples
  # Validates all schema types in a Sanity project with more than one workspace
  sanity schema validate --workspace default

  # Save the results of the report into a file
  sanity schema validate > report.txt

  # Report out only errors
  sanity schema validate --level error

Was this article helpful?