portable-text-conversion
Convert HTML and Markdown content into Portable Text blocks for Sanity.
Skill by sanityOfficial
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/sanity-io-portable-text-conversion
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: documents, frontend, writing
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/portable-text-conversion
What's inside
- Skill name
portable-text-conversion- Description
- Convert HTML and Markdown content into Portable Text blocks for Sanity. Use when migrating content from legacy CMSs, importing HTML or Markdown into Sanity, building content pipelines that ingest external content, converting rich text between formats, or programmatically creating Portable Text documents. Covers @portabletext/markdown (markdownToPortableText), @portabletext/block-tools (htmlToBlocks), custom deserializers, and the Portable Text specification for manual block construction.
- License
- MIT
- Metadata
- author: sanity · version: 1.0.0
- Instructions
- 58 lines in SKILL.md · view on GitHub
Files (4)
- SKILL.md
- html-to-pt.md · rules/
- manual-construction.md · rules/
- markdown-to-pt.md · rules/
SKILL.md (first lines)
# Portable Text Conversion
Convert external content (HTML, Markdown) into Portable Text for Sanity. Three main approaches:
1. **`markdownToPortableText`** — Convert Markdown directly using `@portabletext/markdown` (recommended for Markdown)
2. **`htmlToBlocks`** — Parse HTML into PT blocks using `@portabletext/block-tools` (for HTML migration)
3. **Manual construction** — Build PT blocks directly from any source (APIs, databases, etc.)
## Portable Text Specification
Understand the target format before converting. PT is an array of blocks:
```json
[
{
"_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:**
- Every block and span needs `_key` (unique within the array)
- `_type: "block"` is for text blocks; custom types use their own `_type`
- `markDefs` holds annotation data; `marks` on spans reference `markDefs[*]._key` or are decorator strings
- Lists use `listItem` ("bullet" | "number") and `level` (1, 2, 3...) on regular blocks
## Conversion Rules
Read the rule file matching your source format:
- **Markdown → Portable Text**: `rules/markdown-to-pt.md` — `@portabletext/markdown` with `markdownToPortableText` (recommended)
- **HTML → Portable Text**: `rules/html-to-pt.md` — `@portabletext/block-tools` with `htmlToBlocks`
- **Manual PT Construction**: `rules/manual-construction.md` — build blocks programmatically from any source
> **Note:** `@sanity/block-tools` is the legacy package name. Always use `@portabletext/block-tools` for new projects. The API is the same.From sanity-io/agent-toolkit, MIT.
More from sanity-io/agent-toolkit
- 0.794score
sanity-best-practices
sanity-ioOfficial
Sanity development best practices for schema design, GROQ queries, TypeGen, Visual Editing, images, Portable Text, Studio structure, localization, migrations…
SkillAFreshness: A★ 194Claude Code +9 - 0.794score
Sanity
www.sanity.ioOfficial
Direct access to your Sanity projects (content, datasets, releases, schemas) and agent rules
ConnectorAFreshness: ARemote★ 194Claude Code +3 - 0.789score
sanity-form-component-suspense
sanity-ioOfficial
Fix a Sanity Studio custom form component (components.input, components.field, components.item, or a plugin's form.components) that suspends without its own…
SkillAFreshness: A★ 194Claude Code +9 - 0.789score
sanity-singletons
sanity-ioOfficial
Configure singleton documents in a Sanity Studio using the document.singletons registry.
SkillAFreshness: A★ 194Claude Code +9 - 0.749score
sanity-studio-upgrade
sanity-ioOfficial
Produces a tailored Sanity Studio upgrade plan by inspecting the repository's installed versions, config, and source, then reporting only the breaking changes…
SkillBFreshness: B★ 194Claude Code +9 - 0.749score
content-experimentation-best-practices
sanity-ioOfficial
Content experimentation and A/B testing guidance covering experiment design, hypotheses, metrics, sample size, statistical foundations, CMS-managed variants…
SkillBFreshness: B★ 194Claude Code +9 - 0.749score
sanity-migration
sanity-ioOfficial
Plans, implements, and reviews migrations from other CMSes and content systems into Sanity.
SkillBFreshness: B★ 194Claude Code +9 - 0.616score
seo-aeo-best-practices
sanity-ioOfficial
SEO and AEO best practices for metadata, Open Graph, sitemaps, robots.txt, hreflang, JSON-LD structured data, EEAT, and content optimized for search engines…
SkillDFreshness: D★ 194Claude Code +9 - 0.616score
content-modeling-best-practices
sanity-ioOfficial
Structured content modeling guidance for schema design, content architecture, content reuse, references versus embedded objects, separation of concerns, and…
SkillDFreshness: D★ 194Claude Code +9 - 0.611score
portable-text-serialization
sanityOfficial
Render and serialize Portable Text to React, Svelte, Vue, Astro, HTML, Markdown, and plain text.
SkillDFreshness: D★ 194Claude Code +9
Signals
- Stars
- 194
- Forks
- 30
- Open issues
- 6
- Contributors
- 21
- Last commit (this folder)
- Jul 28, 2026 (3 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- Version
- 1.0.0
- License
- MIT
- Repository
- github.com/sanity-io/agent-toolkit
- Website
- www.sanity.io
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from sanity
Cite this page
portable-text-conversion skill. Agent Mart. https://agentmart.dev/skills/sanity-io-portable-text-conversion (last updated 2026-10-24)