Official agent skill

Portable Text Conversion

by sanity-io in sanity-io/agent-toolkit

Convert HTML and Markdown content into Portable Text blocks for Sanity.

OfficialMITAuto-check passedDocuments & Office

Install Portable Text Conversion

skills CLI
$ npx skills add sanity-io/agent-toolkit --skill portable-text-conversion -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install sanity-io/agent-toolkit portable-text-conversion --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/sanity-io/agent-toolkit.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/portable-text-conversion .claude/skills/portable-text-conversion && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
portable-text-conversion
GitHub stars
188
Used in
1 other repo
Token cost
~664 tokens
SKILL.md length
169 words
Files
4
Skills in repo
8
Repo updated
First seen
Licence
MIT

At a glance

Convert HTML and Markdown content into Portable Text blocks for Sanity.

  • Works in 3 steps: markdownToPortableText — Convert… → htmlToBlocks — Parse HTML into PT blocks… → Manual construction — Build PT blocks…
  • Migrating content from legacy CMSs
  • SKILL.md covers Portable Text Specification and Conversion Rules
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Portable Text Conversion is an agent skill from sanity-io/agent-toolkit, published by the product's own GitHub organization. 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.

Its SKILL.md is about 660 tokens, which your agent loads only when the skill is triggered. The skill folder holds 4 other files (for example `rules/html-to-pt.md`, `rules/manual-construction.md` and `rules/markdown-to-pt.md`).

It sits in Documents & Office, covering Markdown. The repository describes itself as: Collection of resources to help AI agents build better with Sanity. The licence is MIT.

When your agent uses it

  • Migrating content from legacy CMSs
  • Markdown into Sanity
  • Building content pipelines that ingest external content
  • Converting rich text between formats

Example prompts

  • “/portable-text-conversion”

Workflow steps

3 steps, taken from the first numbered list in SKILL.md.

  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.)

What it can do on your machine

Read from SKILL.md and the folder at commit 88d6cdf. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are json).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Portable Text Conversion loads about 664 tokens when it runs. Until then it costs about 129 tokens; SKILL.md has 169 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~129
When it runs · the whole SKILL.md, loaded when a task matches
~664

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from sanity-io/agent-toolkit at commit 88d6cdf, republished under its MIT licence (© sanity-io). 169 words, ~664 tokens.

Download SKILL.mdSave it as .claude/skills/portable-text-conversion/SKILL.md (or your agent's skills folder). This skill also uses 3 other files; get the full folder from GitHub.
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
metadata.version
1.0.0

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.

© sanity-io, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 3 other files in skills/portable-text-conversion of sanity-io/agent-toolkit.

  • SKILL.md
  • rules/html-to-pt.md
  • rules/manual-construction.md
  • rules/markdown-to-pt.md

Open the folder on GitHubat commit 88d6cdf

Used in 1 other repository

We found 1 copy of this SKILL.md (exact, near-identical or edited) in other folders, from 1 other GitHub owner. This page covers the copy in sanity-io/agent-toolkit, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Portable Text Conversion next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Portable Text Conversion compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Portable Text Conversion this skillsanity-io/agent-toolkit1881 repos~664Automated safety check: PassMIT
Markdown Article FormatterJimLiu/baoyu-skills26k6 repos~3.5kAutomated safety check: PassMIT
MarkitdownImCa0/just-laws78214 repos~3.2kAutomated safety check: NotesMIT
Obsidian MarkdownAtmosphere/atmosphere3.8k20 repos~1.3kAutomated safety check: PassApache-2.0
Gzh Designisjiamu/gzh-design-skill3.9k1 repos~2.2kAutomated safety check: PassAGPL-3.0
Crosspostingwasp-lang/wasp19k—~1.1kAutomated safety check: PassMIT

Similar skills

  • Markdown Article Formatter

    JimLiu/baoyu-skills

    Reformats plain text or Markdown articles with frontmatter, a title, a summary, headings, bold, lists and code blocks, and saves a separate formatted copy.

    26k GitHub starsUsed in 6 repos~3.5k tokens
    Documents & OfficeAuto-check passed
  • Markitdown

    ImCa0/just-laws

    Convert files and office documents to Markdown. An agent skill from ImCa0/just-laws.

    782 GitHub starsUsed in 14 repos~3.2k tokens
    Documents & OfficeAuto-check: notes
  • Obsidian Markdown

    Atmosphere/atmosphere

    Create and edit Obsidian Flavored Markdown with wikilinks, embeds, callouts, properties, and other Obsidian-specific syntax.

    3.8k GitHub starsUsed in 20 repos~1.3k tokens
    Documents & OfficeAuto-check passed
  • Gzh Design

    isjiamu/gzh-design-skill

    微信公众号文章排版引擎,将 Markdown 转换为可直接粘贴到公众号编辑器的 HTML。主题风格从 references/theme-index.md 注册的自定义主题库中选取,自动章节编号、关键词下划线标记、引言卡片、目录导航、代码块、图片/GIF、作者签名。支持 Markdown / Word(.docx) / PDF / 纯文本输入(非 Markdown…

    3.9k GitHub starsUsed in 1 repo~2.2k tokens
    Documents & OfficeAuto-check passed
  • Crossposting

    wasp-lang/wasp

    Crosspost Wasp blog articles (MDX) to DEV.to and Medium. An agent skill from wasp-lang/wasp.

    19k GitHub stars~1.1k tokensUpdated yesterday
    Documents & OfficeAuto-check passed
  • Review The Docs

    supabase/supabase

    Official

    Review Supabase docs changes locally in your supabase/supabase checkout — either an open PR (triage, classify, verify) or your own branch before opening a PR (local self-review).

    111k GitHub stars~4.6k tokensUpdated today
    Documents & OfficeAuto-check passed

More from sanity-io/agent-toolkit

All 8 skills in this repo
  • Sanity Best Practices

    sanity-io/agent-toolkit

    Official

    Sanity development best practices for schema design, GROQ queries, TypeGen, Visual Editing, images, Portable Text, Studio structure, localization, migrations, Sanity Functions, webhooks, Blueprints…

    188 GitHub stars~1.3k tokensUpdated 4 days ago
    Auto-check passed
  • Sanity Migration

    sanity-io/agent-toolkit

    Official

    Plans, implements, and reviews migrations from other CMSes and content systems into Sanity.

    188 GitHub stars~1.4k tokensUpdated 4 days ago
    Auto-check passed
  • Portable Text Serialization

    sanity-io/agent-toolkit

    Official

    Render and serialize Portable Text to React, Svelte, Vue, Astro, HTML, Markdown, and plain text.

    188 GitHub starsUsed in 1 repo~1.1k tokens
    Auto-check passed
  • SEO Aeo Best Practices

    sanity-io/agent-toolkit

    Official

    SEO and AEO best practices for metadata, Open Graph, sitemaps, robots.txt, hreflang, JSON-LD structured data, EEAT, and content optimized for search engines and AI answer surfaces.

    188 GitHub starsUsed in 2 repos~467 tokens
    Auto-check passed
  • Sanity Studio Upgrade

    sanity-io/agent-toolkit

    Official

    Produces a tailored Sanity Studio upgrade plan by inspecting the repository's installed versions, config, and source, then reporting only the breaking changes that actually apply.

    188 GitHub stars~4.8k tokensUpdated 4 days ago
    Auto-check passed
  • Official

    Content experimentation and A/B testing guidance covering experiment design, hypotheses, metrics, sample size, statistical foundations, CMS-managed variants, and common analysis pitfalls.

    188 GitHub starsUsed in 1 repo~469 tokens
    Auto-check passed

Questions about Portable Text Conversion

What does Portable Text Conversion do?

Convert HTML and Markdown content into Portable Text blocks for Sanity. Portable Text Conversion is an agent skill from sanity-io/agent-toolkit, published by the product's own GitHub organization. Convert HTML and Markdown content into Portable Text blocks for Sanity.

When should I use Portable Text Conversion?

Portable Text Conversion fits situations like: migrating content from legacy CMSs; markdown into Sanity; building content pipelines that ingest external content; converting rich text between formats.

How do I install Portable Text Conversion in Claude Code?

Run `npx skills add sanity-io/agent-toolkit --skill portable-text-conversion -a claude-code`. Or copy the skill folder (skills/portable-text-conversion in sanity-io/agent-toolkit) into .claude/skills/portable-text-conversion in your project. Claude Code loads it when a task matches its description.

How do I install Portable Text Conversion in Codex?

Run `npx skills add sanity-io/agent-toolkit --skill portable-text-conversion -a codex`. Or copy the skill folder (skills/portable-text-conversion in sanity-io/agent-toolkit) into .agents/skills/portable-text-conversion in your project. Codex loads it when a task matches its description.

Can I use Portable Text Conversion in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add sanity-io/agent-toolkit --skill portable-text-conversion -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/portable-text-conversion, .gemini/skills/portable-text-conversion, .github/skills/portable-text-conversion and .opencode/skills/portable-text-conversion in your project.

What does Portable Text Conversion need to run?

SKILL.md names no scripts, command-line tools or credentials: Portable Text Conversion is instructions for the agent only.

Does Portable Text Conversion access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Portable Text Conversion safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Portable Text Conversion use?

Portable Text Conversion is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Portable Text Conversion use?

About 664 tokens (SKILL.md is roughly 2.7k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Portable Text Conversion?

Skills that share tags, products or a category with Portable Text Conversion: Markdown Article Formatter (JimLiu/baoyu-skills, 26k stars), Markitdown (ImCa0/just-laws, 782 stars), Obsidian Markdown (Atmosphere/atmosphere, 3.8k stars) and Gzh Design (isjiamu/gzh-design-skill, 3.9k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Portable Text Conversion?

sanity-io (a GitHub organization, an official publisher) maintains it in sanity-io/agent-toolkit, which has 188 GitHub stars. The repository holds 8 skills in this directory. The repository was last updated on October 5, 2026.

Source: sanity-io/agent-toolkit on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.