Dictionary to BlockNote Converter¶
The dict_to_blocks() function converts Python dictionaries into BlockNote blocks.
Function Signature¶
Parameters¶
- data (
List[Dict[str, Any]]): List of dictionaries representing blocks
Returns¶
- List[Block]: List of validated BlockNote Block objects
Basic Usage¶
from blocknote.converter import dict_to_blocks
data = [
{
"id": "1",
"type": "paragraph",
"props": {},
"content": [
{
"type": "text",
"text": "Hello, World!",
"styles": {}
}
],
"children": []
}
]
blocks = dict_to_blocks(data)
print(blocks[0].content[0].text) # "Hello, World!"
Dictionary Format¶
Each dictionary must contain:
- id: Unique string identifier
- type: Block type (paragraph, heading, etc.)
- props: Block properties (optional)
- content: List of content objects or string
- children: List of child block dictionaries (optional)
Validation¶
The converter validates: - Required fields are present - Block types are valid - Content structure is correct - Nested children are properly formatted