User guides

Copy and paste fields

How to copy and paste fields and documents within your Sanity Studio.

The field copy-and-paste feature in Sanity Studio enables you to copy and paste field values or entire documents within your Studio. This feature can be a significant time saver when you need to duplicate content or move it between different document types.

You can access these specialized copy-and-paste actions in the following ways:

  • Through the Field Actions menu on individual fields.
  • Using the standard Ctrl/Cmd+C and Ctrl/Cmd+V keyboard shortcuts on supported field types.

Copy and paste fields

To copy and paste individual fields within a document:

  • Hover over a field to reveal the Field Actions menu.
Loading...
  • Select Copy field to copy the contents of that field.
  • Navigate to another field of the same type and select Paste field in the Field Actions menu to paste the copied content.

Additionally, certain field types support using the standard Ctrl/Cmd+C and Ctrl/Cmd+V keyboard shortcuts for copying and pasting:

  • Array fields
  • Object fields
  • Reference fields
  • Image and file fields

Using keyboard shortcuts can be a quick way to duplicate content within these field types.

Copy and paste documents

To copy and paste entire documents:

  • Open the Document Actions menu and select Copy document to copy the current document to your clipboard.
Loading...
  • Navigate to the document list where you want to create a new document.
  • Create a new document.
  • Select Paste document from the Document Actions menu or use the keyboard shortcut Ctrl/Cmd+V.

Another advantage of the copy/paste workflow over using the Duplicate action is that you can paste documents across different document types. The Studio will try to map the fields from the source to the destination document.

Examples

Here are some examples where copy-and-paste for fields can come in handy.

Copying between array types

There might be cases where it's more efficient to copy existing items from an array into a new one and edit them. For example, if you use array fields to build things like landing pages and newsletters, and want to keep the same structure or have minor variations between them.

Note that pasting into an array will replace all the items in it. However, if you do this accidentally, you can use Review changes and restore to the content you want to keep.

Copying between object types

Say you have an object field of type bio with the fields name, image, and history. If you copy that entire object and paste it into an object field of type author which has the fields name and image, the Studio will transfer over the field values that are in common between the two types (name and image) and discard the field that doesn't exist in the destination (history).

Copying between document types

Similarly, if you copy a whole document of type author and paste it into a document of type person, the Studio will copy over any fields that the two document types have in common (e.g., name and image). Fields that do not exist in the destination type (e.g., publicationsList in author) will be discarded.

If only some of the copied fields exist in the destination, you'll see a "Could not paste all values" warning describing what couldn't be transferred. If none of the copied fields exist in the destination — or there's nothing on your clipboard when you try to paste — you'll get a "Nothing to paste" notification instead.

Limitations

There are a few known limitations to be aware of with the new copy-and-paste feature:

  • When pasting a reference, Studio checks that the referenced document exists, that its type is allowed by the target field, and that it satisfies any filter set on the field. Pasting is asynchronous for this reason, and you'll see an error if the reference can't be used in the target field.
  • For images and files, Studio fetches the asset document to check its MIME type against the target field's accept option, and blocks the paste if the type isn't accepted.
  • When focused inside a text input, copy and paste is handled by the input's own clipboard event management to avoid interfering with native editing behaviors such as undo and redo.
  • Pasting a whole array field into another array field replaces the entire array rather than appending to it. A single copied array item, by contrast, is appended to the end of the target array. This replace behavior might be unexpected for users accustomed to appending when pasting in other contexts.
  • Arrays of anonymous object types, sometimes referred to as inline objects, are supported — Studio resolves the item's type from the array's member types.

Was this page helpful?