Loading...
Loading...
Render and serialize Portable Text to React, Svelte, Vue, Astro, HTML, Markdown, and plain text. Use when implementing Portable Text rendering in any frontend framework, building custom serializers for non-standard block types, converting Portable Text to HTML strings server-side, converting Portable Text to Markdown, extracting plain text from Portable Text, or troubleshooting rendering issues with marks, blocks, lists, or custom types.
npx skill4agent add sanity-io/agent-toolkit portable-text-serialization@portabletext/*components_typestylechildrenmarkDefslistItemlevelRoot array
├── block (_type: "block")
│ ├── style: "normal" | "h1" | "h2" | "blockquote" | ...
│ ├── children: [span, span, ...]
│ │ └── span: { _type: "span", text: "...", marks: ["strong", "<markDefKey>"] }
│ ├── markDefs: [{ _key, _type: "link", href: "..." }, ...]
│ ├── listItem: "bullet" | "number" (optional)
│ └── level: 1, 2, 3... (optional, for nested lists)
├── custom block (_type: "image" | "code" | any custom type)
└── ...more blocksmarks[]"strong""em""underline""code"marks[]markDefs[]@portabletext/*components| Key | Renders | Props/Data |
|---|---|---|
| Custom block/inline types (image, code, CTA) | |
| Decorators + annotations | |
| Block styles (h1, normal, blockquote) | |
| List wrappers (ul, ol) | |
| List items | |
| Line breaks within a block | — |
rules/react.md@portabletext/reactnext-sanityrules/svelte.md@portabletext/svelterules/vue.md@portabletext/vuerules/astro.mdastro-portabletextrules/html.md@portabletext/to-htmlrules/markdown.md@portabletext/markdownrules/plain-text.md@portabletext/toolkit| Target | Package |
|---|---|
| React Native | |
| React PDF | |
| Solid | |
| Qwik | |
| Shopify Liquid | |
| PHP | |
| Python | |
| C# / .NET | |
| Dart / Flutter | |
imagecodecallToActioncomponentsonMissingComponentfalsebody[]{
...,
_type == "image" => {
...,
asset->
},
markDefs[]{
...,
_type == "internalLink" => {
...,
"slug": @.reference->slug.current
}
}
}