Sanity CLI
Manage Sanity.io content platform from the command line
Description
Sanity CLI is the official command-line tool for Sanity.io, the composable content platform. It lets you initialize projects, manage datasets, deploy Sanity Studio, run GraphQL APIs, export and import data, and develop custom content schemas locally.
Install
npm i -g @sanity/cliAI Summary
Official Sanity.io CLI for initializing projects, managing datasets, deploying Sanity Studio, running GraphQL APIs, and handling content data import/export.
Capabilities
- + Initialize and scaffold new Sanity projects
- + Run Sanity Studio locally for development
- + Deploy Sanity Studio to Sanity hosting
- + Export and import datasets for backup and migration
- + Deploy and manage GraphQL API endpoints
- + Manage datasets and project configuration
Use When
- → Developing and deploying Sanity.io content projects
- → Managing Sanity datasets and content from the terminal
- → Exporting or importing Sanity data for backup or migration
- → Running Sanity Studio locally during development
Avoid When
- x Not using Sanity.io as your content platform
- x Prefer the Sanity web UI for all content management
- x Managing non-CMS cloud infrastructure
Usage Patterns
Create a new Sanity project
sanity init --project-plan free Scaffolds a new Sanity project with interactive setup
Start local development
sanity start Launches Sanity Studio at localhost:3333 for development
Export a dataset
sanity dataset export production ./backup.tar.gz Exports the production dataset to a compressed archive
Deploy the Studio
sanity deploy Deploys Sanity Studio to the hosted Sanity URL
Input / Output
Typical Pipelines
sanity dataset export production ./backup.tar.gz to create a full dataset backup sanity dataset create staging && sanity dataset import ./backup.tar.gz staging to clone production to staging sanity graphql deploy && curl the endpoint to deploy and verify GraphQL API