What you will learn
An editable rectangle inserted from a small, valid JSON snippet.
Before you start
- A board open with room for a practice shape.
- Code Snippet Runner visible in the right toolbar; enable it in Feature Settings if needed.
- Basic comfort copying and editing plain text.
1. Open the snippet tool
Choose Code Snippet Runner in the right toolbar. This tool reads JSON that describes whiteboard elements, tables, or mind maps and inserts that content onto the canvas. It is not a JavaScript execution console.
Start with one simple shape so the connection between the text and the result is easy to see. You do not need an AI service or generated content for this lesson.
2. Use the built-in rectangle example
Choose Samples, then Simple Rectangle. This loads the example into the text area; it has not been inserted yet. The sample describes a rectangle using fields such as type, width, and backgroundColor.
You can also paste this same small example manually:
[
{
"type": "rectangle",
"x": 0,
"y": 0,
"width": 200,
"height": 100,
"strokeColor": "#1e1e1e",
"backgroundColor": "#a5d8ff",
"fillStyle": "solid",
"roughness": 1,
"opacity": 100
}
]
Keep the square brackets, braces, commas, and double quotes. The numeric values should remain numbers.
3. Make one small change
Change width from 200 to 280, leaving the rest alone. That makes the rectangle wider. Or keep its size and change backgroundColor to "#b2f2bb" for a green fill.
Use the text area’s normal editing controls. The Paste button reads your clipboard, and Clear clears the input. If clipboard access is unavailable, click inside the text area and paste with your usual keyboard command.
Change one value, then compare the shape
Only width changes from 200 to 280; height stays 100. These are actual outputs of the Simple Rectangle JSON, moved apart for comparison. Open full-size image.
Keep the full Simple Rectangle JSON and change only width.
4. Insert the shape onto the canvas
Choose Insert to Canvas. The tool checks the JSON before inserting it. On success, it reports that one element was inserted, clears the input, and closes the dialog shortly afterward.
The rectangle is added to the existing board near the center of the current view and becomes selected. The example’s x and y coordinates describe its source placement; insertion centers the supplied elements together in the viewport rather than requiring you to find canvas origin zero.
5. Continue editing normally
Use the whiteboard’s usual selection and styling tools to move or adjust the inserted rectangle. The snippet has produced an editable canvas element, so you can continue working visually without rewriting the JSON.
When you are comfortable, browse another built-in sample. The tool also accepts table and mind-map snippets, but each has its own data format. Save your board through Save & Export when you want to keep the result.
Try it yourself
Insert the unchanged Simple Rectangle sample once. Reopen the runner, load the sample again, change only the width or fill color, and insert a second rectangle. Move them apart on the canvas and compare the result. This makes it clear which part of the JSON caused the visible difference.
If you get stuck
Why do I see Invalid JSON?
Check that keys and text use double quotes, commas separate fields, and brackets are balanced. Start again from Simple Rectangle if needed. JavaScript statements are not a supported input format.
The JSON is valid, but why is there no insertable content?
Valid JSON must also describe supported content. Element items need at least type, x, and y; the supplied rectangle example includes useful size and style fields too.
Can I paste a whole explanation around the JSON?
Paste the drawing data rather than a surrounding explanation. The parser supports JSON code fences and comments, but ordinary prose outside the JSON will prevent parsing.
Does Insert replace the board?
The ordinary element snippet used in this lesson appends new elements to the current board. Repeated insertion creates another copy.
Based on Whiteboard Vibe for Chrome 5.2.2. Tool names and options may vary in other versions.

