From sanity
Converts HTML and Markdown into Sanity Portable Text blocks using @portabletext/markdown (markdownToPortableText) and @portabletext/block-tools (htmlToBlocks). Also covers manual block construction per the Portable Text spec.
How this skill is triggered — by the user, by Claude, or both
Slash command
/sanity:portable-text-conversionThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Convert external content (HTML, Markdown) into Portable Text for Sanity. Three main approaches:
Convert external content (HTML, Markdown) into Portable Text for Sanity. Three main approaches:
markdownToPortableText — Convert Markdown directly using @portabletext/markdown (recommended for Markdown)htmlToBlocks — Parse HTML into PT blocks using @portabletext/block-tools (for HTML migration)Understand the target format before converting. PT is an array of blocks:
[
{
"_type": "block",
"_key": "abc123",
"style": "normal",
"children": [
{"_type": "span", "_key": "def456", "text": "Hello ", "marks": []},
{"_type": "span", "_key": "ghi789", "text": "world", "marks": ["strong"]}
],
"markDefs": []
},
{
"_type": "block",
"_key": "jkl012",
"style": "h2",
"children": [
{"_type": "span", "_key": "mno345", "text": "A heading", "marks": []}
],
"markDefs": []
},
{
"_type": "image",
"_key": "pqr678",
"asset": {"_type": "reference", "_ref": "image-abc-200x200-png"}
}
]
Key rules:
_key (unique within the array)_type: "block" is for text blocks; custom types use their own _typemarkDefs holds annotation data; marks on spans reference markDefs[*]._key or are decorator stringslistItem ("bullet" | "number") and level (1, 2, 3...) on regular blocksRead the rule file matching your source format:
rules/markdown-to-pt.md — @portabletext/markdown with markdownToPortableText (recommended)rules/html-to-pt.md — @portabletext/block-tools with htmlToBlocksrules/manual-construction.md — build blocks programmatically from any sourceNote:
@sanity/block-toolsis the legacy package name. Always use@portabletext/block-toolsfor new projects. The API is the same.
npx claudepluginhub sanity-io/agent-toolkit --plugin sanityPlans and implements content migrations from AEM, Contentful, Strapi, Webflow, WordPress, Drupal, Payload, Markdown/MDX, and other sources into Sanity CMS with Portable Text conversion, asset migration, redirects, and validation.
Generates a step-by-step conversion brief for moving articles from Word, plain text, or InDesign to Markdown, HTML, or structured plain text, preserving editorial elements.
Converts a page's raw HTML into WordPress block-editor markup using design tokens and a screenshot. Call per-page after extraction to produce `post_content` that renders with the theme's tokens and patterns.