In short.
Portable Text Conversion is a Sanity assistant skill for developers migrating rich content, but it provides guidance and adaptable examples rather than a ready-to-run migration. Its four files explain how to choose a conversion route, map formatting to a schema, construct valid blocks and handle image assets. The examples expose useful implementation details, including top-level Markdown matchers and the distinction between dataset-import image references and client uploads. Dependency versions, agent installation steps, conversion fidelity and operating costs are not established. No code was executed.
Researched and written by an AI model and checked by a second AI model. How it works
Coverage includes the complete skills/portable-text-conversion folder at commit 3ed3a143f8d3413faa7790ac0b2274fd3a8a6320: SKILL.md and rules/html-to-pt.md, rules/manual-construction.md and rules/markdown-to-pt.md, plus the repository-root LICENSE. Other toolkit skills, linked documentation, dependency implementations and external content are excluded. No installation, conversion, upload or migration was executed. Runtime compatibility, output fidelity, performance and operating costs remain unknown.
The overview
Identity
Portable Text Conversion belongs to Sanity's agent-toolkit repository. It is an assistant skill: a SKILL.md entry point directs the assistant to three supporting guides for Markdown conversion, HTML conversion and manual construction. Its metadata identifies Sanity as the author and declares skill version 1.0.0.
The original folder is [https://github.com/sanity-io/agent-toolkit/tree/main/skills/portable-text-conversion]. The source snapshot is pinned to commit 3ed3a143f8d3413faa7790ac0b2274fd3a8a6320. The conversion libraries it describes are separate dependencies.
Assessment
The skill is a useful starting point for developers who need an assistant to help produce Sanity migration code. Its strongest feature is the clear choice between direct Markdown conversion, schema-aware HTML parsing and manual construction.
The examples require engineering work before use on a real collection. Custom schema types, asset handling and document replacement behavior need explicit decisions. No execution results establish that the examples work with a particular dependency combination or preserve a particular collection's content.
Who it is for
The intended users are developers moving articles from a legacy CMS, importing Markdown files, ingesting external HTML or generating Sanity rich text from APIs and databases. Beginners receive concrete examples of paragraphs, headings, links and lists; experienced developers receive schema mapping and custom deserializer patterns.
Using the migration examples requires JavaScript or TypeScript knowledge and familiarity with the destination Sanity schema. The files do not provide an end-user import interface or a full introduction to administering Sanity.
Capabilities
The Markdown guide documents headings, paragraphs, text formatting, links, nested lists, code blocks, images and GFM tables. It also shows custom style mappings, block and mark matchers, configurable inline HTML handling, custom key generation and a Sanity schema bridge. These are documented library capabilities, not measured results.
The HTML guide covers schema compilation, DOM parsing, content cleanup and custom rules for images, links and embeds. The manual guide explains direct construction of text blocks, annotations, lists and custom objects. The Markdown guide also identifies portableTextToMarkdown for conversion in the opposite direction, without covering that route in comparable detail.
Using it
Requirements
The Markdown route uses @portabletext/markdown. Custom schema examples additionally use @portabletext/schema or @portabletext/sanity-bridge. The HTML setup installs @portabletext/block-tools, jsdom and @sanity/schema; in Node.js, htmlToBlocks needs a parseHtml function returning a DOM Document.
The supplied client-write example needs a Sanity project ID, dataset and token. The destination schema must support the styles, annotations and custom objects being generated. Exact dependency versions, Node.js requirements and compatible assistant hosts are not specified.
How it works
Portable Text represents rich content as an array of structured objects. Text blocks contain spans, formatting marks and annotation definitions. Links connect a span's marks to matching entries in markDefs; lists use listItem and level on ordinary text blocks.
markdownToPortableText converts Markdown directly into this structure. htmlToBlocks parses a DOM using a compiled Sanity block-content type and optional deserializer rules. Manual construction builds the same objects directly, with keys, styles and custom types checked against the destination schema.
Setup
Choose the guide matching the input format. For Markdown, the documented installation is npm install @portabletext/markdown, followed by importing markdownToPortableText. For HTML, install the three documented dependencies, compile the destination block-content schema and supply JSDOM through parseHtml.
Extend the schema before emitting custom objects or annotation fields. For images written through the client or mutation API, upload the asset and populate asset._ref; the guide says _sanityAsset image URLs are resolved only by sanity datasets import. Instructions for installing this skill into a particular assistant are not provided.
Example use
For a folder of Markdown articles, the supplied example reads each .md file, separates front matter with gray-matter and converts the remaining content with markdownToPortableText. It then uses @sanity/client to write a post document whose title comes from front matter and whose body contains the converted blocks.
Document IDs are derived from filenames, and the write operation uses createOrReplace. A developer adapting this example needs to decide how matching existing documents should be handled. This is a source example; no import was run and no resulting documents were inspected.
Assessment & evidence
Limitations
The HTML examples are not fully aligned as a single configuration. The sample schema defines text blocks, images and links with href, while later deserializers emit embed objects and an optional link target field. Preserving those outputs requires corresponding schema definitions.
The longer HTML migration references an undefined fetchWordPressPosts helper and leaves custom rules as a placeholder. Its image deserializer also leaves asset._ref empty, so that example needs the documented import-specific asset resolution or a separate upload step.
The folder supplies guidance rather than a complete migration application. Dependency compatibility, conversion fidelity, throughput, malformed-input handling and round-trip preservation are not assessed. Support for a listed format feature does not establish preservation of every source document's structure.
Why it may fit
The practical value comes from connecting input format to implementation choices. Markdown receives a direct conversion route; HTML receives DOM parsing and custom deserializers; structured data receives explicit block-construction rules. This gives an assistant concrete patterns to apply instead of treating every migration alike.
The schema checks and asset-path distinction make the guidance particularly relevant to Sanity migrations. Its suitability is strongest when a developer can adapt and inspect the generated code; the evidence does not establish unattended migration reliability.
Alternative approaches
Developers who need only the conversion API can work directly with the libraries identified by the skill. The documented choice is @portabletext/markdown for Markdown and @portabletext/block-tools for HTML requiring DOM rules. The guide directs new HTML work to @portabletext/block-tools rather than the legacy @sanity/block-tools package name.
For API records, database content or precise control over custom objects, manual construction is the documented alternative. It makes the developer responsible for keys, annotation references and schema compatibility. The evidence does not compare competing migration products or establish a performance winner.
Evidence
The resource consists of SKILL.md and the three rule files html-to-pt.md, manual-construction.md and markdown-to-pt.md. Together they provide instructional text, schema examples, conversion calls, migration sketches and validation guidance. The repository LICENSE supplies the accompanying rights notice.
These files support an assessment of the guidance and its examples. They do not provide execution receipts, benchmark measurements or inspected migration outputs. The linked conversion libraries' implementations and tests are outside this skill folder.
Access & freshness
Costs
The MIT licence permits reuse of the supplied skill without specifying a licence fee. The files do not state Sanity service prices, assistant or model charges, hosting costs, or migration infrastructure costs. Total operating cost is unknown; the licence does not establish that running a migration is free.
Rights and licence
The repository notice is the MIT License, copyright 2025 Sanity, and the skill metadata also declares MIT. The notice permits use, modification, redistribution, sublicensing and sale, provided the copyright and permission notice accompany copies or substantial portions. It supplies the software without warranty.
This notice supports redistribution of the captured skill files with the licence included. It does not establish rights to imported articles, remote images or other third-party content, nor does it establish the separate dependencies' licence terms.
Version and freshness
The source snapshot was captured on 16 November 2026 at commit 3ed3a143f8d3413faa7790ac0b2274fd3a8a6320. SKILL.md declares version 1.0.0; that version identifies the skill, not the npm libraries it references.
The examples do not pin dependency versions. Compatibility with current package releases and changes after the captured commit are unknown. The capture date does not establish when the guidance was last updated or validated.
Practical next steps
Choose the conversion route from the actual source format, then map its styles, lists, annotations and custom objects to the destination schema. Confirm dependency APIs and versions before adapting the examples. For HTML, decide how images will be uploaded and add schema definitions for any custom deserializer output.
Before a live import, inspect representative converted documents for missing text, links, nested lists, tables and images. Check keys and annotation references against the manual guide's validation rules. Review generated document IDs and createOrReplace behavior; the HTML guide's final command explicitly disables dry run. These are recommended next steps, not completed checks.
