Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Interact with the Notion REST API to read, create, update, and delete pages, databases, and blocks.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/rich-text.md
1# Notion Rich Text Reference23This document provides comprehensive documentation for rich text objects in the Notion API.45## Rich Text Array Structure67Rich text in Notion is represented as an array of rich text objects. Each block or property that supports formatted text uses this structure:89```json10{11"rich_text": [12{13"type": "text",14"text": {"content": "Hello "},15"annotations": {"bold": false, "italic": false, "strikethrough": false, "underline": false, "code": false, "color": "default"},16"plain_text": "Hello ",17"href": null18},19{20"type": "text",21"text": {"content": "world", "link": {"url": "https://example.com"}},22"annotations": {"bold": true, "italic": false, "strikethrough": false, "underline": false, "code": false, "color": "default"},23"plain_text": "world",24"href": "https://example.com"25}26]27}28```2930## Common Fields3132All rich text objects contain:3334| Field | Type | Description |35|-------|------|-------------|36| `type` | string | The type of rich text object |37| `annotations` | object | Styling applied to the text |38| `plain_text` | string | Plain text without formatting |39| `href` | string or null | URL if the text is a link |4041---4243## Rich Text Types4445### Text4647Basic text content with optional link:4849```json50{51"type": "text",52"text": {53"content": "Link text",54"link": {"url": "https://example.com"}55},56"annotations": { /* ... */ },57"plain_text": "Link text",58"href": "https://example.com"59}60```6162Without link:6364```json65{66"type": "text",67"text": {68"content": "Plain text"69},70"annotations": { /* ... */ },71"plain_text": "Plain text",72"href": null73}74```7576### Equation7778Inline mathematical expressions using LaTeX/KaTeX:7980```json81{82"type": "equation",83"equation": {84"expression": "E = mc^2"85},86"annotations": { /* ... */ },87"plain_text": "E = mc^2",88"href": null89}90```9192### Mention9394References to other Notion objects or users.9596#### User Mention9798```json99{100"type": "mention",101"mention": {102"type": "user",103"user": {104"object": "user",105"id": "user-uuid",106"name": "John Doe",107"avatar_url": "https://...",108"type": "person",109"person": {"email": "[email protected]"}110}111},112"annotations": { /* ... */ },113"plain_text": "@John Doe",114"href": "https://www.notion.so/user-uuid"115}116```117118#### Page Mention119120```json121{122"type": "mention",123"mention": {124"type": "page",125"page": {126"id": "page-uuid"127}128},129"annotations": { /* ... */ },130"plain_text": "Page Title",131"href": "https://www.notion.so/page-uuid"132}133```134135**Note**: If the integration doesn't have access to the mentioned page, only the ID is returned.136137#### Database Mention138139```json140{141"type": "mention",142"mention": {143"type": "database",144"database": {145"id": "database-uuid"146}147},148"annotations": { /* ... */ },149"plain_text": "Database Title",150"href": "https://www.notion.so/database-uuid"151}152```153154#### Date Mention155156```json157{158"type": "mention",159"mention": {160"type": "date",161"date": {162"start": "2024-01-15",163"end": null,164"time_zone": null165}166},167"annotations": { /* ... */ },168"plain_text": "January 15, 2024",169"href": null170}171```172173With date range:174175```json176{177"type": "mention",178"mention": {179"type": "date",180"date": {181"start": "2024-01-15",182"end": "2024-01-20",183"time_zone": null184}185},186"annotations": { /* ... */ },187"plain_text": "January 15, 2024 → January 20, 2024",188"href": null189}190```191192#### Link Preview Mention193194```json195{196"type": "mention",197"mention": {198"type": "link_preview",199"link_preview": {200"url": "https://github.com/..."201}202},203"annotations": { /* ... */ },204"plain_text": "https://github.com/...",205"href": "https://github.com/..."206}207```208209#### Template Mention (Date)210211Used in template blocks for dynamic dates:212213```json214{215"type": "mention",216"mention": {217"type": "template_mention",218"template_mention": {219"type": "template_mention_date",220"template_mention_date": "today"221}222},223"annotations": { /* ... */ },224"plain_text": "@today",225"href": null226}227```228229Template date options: `today`, `now`230231#### Template Mention (User)232233Used in template blocks for dynamic user references:234235```json236{237"type": "mention",238"mention": {239"type": "template_mention",240"template_mention": {241"type": "template_mention_user",242"template_mention_user": "me"243}244},245"annotations": { /* ... */ },246"plain_text": "@me",247"href": null248}249```250251---252253## Annotations254255Annotations control text styling:256257```json258{259"annotations": {260"bold": false,261"italic": false,262"strikethrough": false,263"underline": false,264"code": false,265"color": "default"266}267}268```269270| Property | Type | Description |271|----------|------|-------------|272| `bold` | boolean | Bold text |273| `italic` | boolean | Italic text |274| `strikethrough` | boolean | Strikethrough text |275| `underline` | boolean | Underlined text |276| `code` | boolean | Inline code styling |277| `color` | string | Text or background color |278279### Color Options280281Text colors:282- `default`283- `gray`284- `brown`285- `orange`286- `yellow`287- `green`288- `blue`289- `purple`290- `pink`291- `red`292293Background colors:294- `gray_background`295- `brown_background`296- `orange_background`297- `yellow_background`298- `green_background`299- `blue_background`300- `purple_background`301- `pink_background`302- `red_background`303304---305306## Creating Rich Text307308### Simple Text309310```json311[312{313"type": "text",314"text": {"content": "Simple text"}315}316]317```318319### Formatted Text320321```json322[323{324"type": "text",325"text": {"content": "Bold and italic"},326"annotations": {"bold": true, "italic": true}327}328]329```330331### Mixed Formatting332333```json334[335{"type": "text", "text": {"content": "Normal "}},336{"type": "text", "text": {"content": "bold"}, "annotations": {"bold": true}},337{"type": "text", "text": {"content": " and "}},338{"type": "text", "text": {"content": "italic"}, "annotations": {"italic": true}},339{"type": "text", "text": {"content": " text."}}340]341```342343### Text with Link344345```json346[347{"type": "text", "text": {"content": "Check out "}},348{349"type": "text",350"text": {"content": "this link", "link": {"url": "https://example.com"}}351},352{"type": "text", "text": {"content": " for more info."}}353]354```355356### Code Styling357358```json359[360{"type": "text", "text": {"content": "Use the "}},361{"type": "text", "text": {"content": "console.log()"}, "annotations": {"code": true}},362{"type": "text", "text": {"content": " function."}}363]364```365366### Colored Text367368```json369[370{371"type": "text",372"text": {"content": "Important!"},373"annotations": {"color": "red", "bold": true}374}375]376```377378### With Background Color379380```json381[382{383"type": "text",384"text": {"content": "Highlighted text"},385"annotations": {"color": "yellow_background"}386}387]388```389390### User Mention391392```json393[394{"type": "text", "text": {"content": "Assigned to "}},395{396"type": "mention",397"mention": {398"type": "user",399"user": {"id": "user-uuid"}400}401}402]403```404405### Page Mention406407```json408[409{"type": "text", "text": {"content": "See also: "}},410{411"type": "mention",412"mention": {413"type": "page",414"page": {"id": "page-uuid"}415}416}417]418```419420### Date Mention421422```json423[424{"type": "text", "text": {"content": "Due: "}},425{426"type": "mention",427"mention": {428"type": "date",429"date": {"start": "2024-12-31"}430}431}432]433```434435### Inline Equation436437```json438[439{"type": "text", "text": {"content": "The formula is "}},440{"type": "equation", "equation": {"expression": "x = \\frac{-b \\pm \\sqrt{b^2-4ac}}{2a}"}},441{"type": "text", "text": {"content": "."}}442]443```444445---446447## Limits448449| Type | Limit |450|------|-------|451| Rich text content | 2000 characters per rich text object |452| Rich text array | 100 items max |453| Equations | 1000 characters |454455---456457## Reading Rich Text458459When processing rich text from API responses, you can:4604611. **Get plain text**: Concatenate all `plain_text` values4622. **Preserve formatting**: Process each object and apply `annotations`4633. **Extract links**: Check `href` field or `text.link.url`464465Example (JavaScript):466467```javascript468function getPlainText(richTextArray) {469return richTextArray.map(rt => rt.plain_text).join('');470}471472function getLinks(richTextArray) {473return richTextArray474.filter(rt => rt.href)475.map(rt => ({text: rt.plain_text, url: rt.href}));476}477```478479Example (bash with jq):480481```bash482# Get plain text483echo "$rich_text_json" | jq -r '[.[].plain_text] | join("")'484485# Get all links486echo "$rich_text_json" | jq '[.[] | select(.href != null) | {text: .plain_text, url: .href}]'487```488