---
title: "Code blocks"
url: "/docs/reference/code-blocks"
description: "The fenced code blocks 10nx draws live: run buttons, diagrams, charts, tables, diffs and voice blocks"
---

# Code blocks

Every fenced code block gets a toolbar with a language picker and **Copy**. Some languages get more: a **Run** button, a diagram, a chart, an editable grid. On disk each one is still a plain fenced block, so the note stays readable in any other app. The block's toolbar flips between the source and the drawn view.

Use this page to find which fence does what, and what goes inside it.

## The blocks

| Fence | Draws | Body |
| --- | --- | --- |
| any language | Syntax colours, language picker, Copy | The code |
| `bash` `sh` `zsh` `shell` | A green **Run** that runs the block in the terminal's Shell tab | The script |
| `python` `py` | **Run**, through `uv run python` | The script |
| `mermaid` | A diagram | Mermaid source, written flush-left |
| `chart` | A line, area, bar or scatter chart | CSV with a header row, or JSON |
| `database` | An editable grid: text, number, checkbox, select, date and formula columns | `{"columns": […], "rows": […]}` |
| `datatable` | A read-only, sortable table with optional totals | A JSON array of rows, or `{"data": […]}` |
| `diff` | A red and green diff, split or unified, with line comments | A unified diff |
| `worktree` | This note across your worktrees: which have a copy, and how it differs | `{"rows": ["main", "fix-login"]}`, or empty for all |
| `audio_recording` | A recorder, then transcript, summary and template tabs | Written by 10nx |
| `dictation` | Live dictation | Written by 10nx |
| `voice-note` | A voice note, raw and refined | Written by 10nx |

Insert the last three from the `/` menu, not by hand. The Python **Run** needs [uv](https://docs.astral.sh/uv/).

## Examples

A chart from CSV:

````markdown
```chart
date,weight
2026-01-01,80.1
2026-01-08,79.6
2026-01-15,79.2
```
````

A chart with options:

````markdown
```chart
{"type": "bar", "x": "month", "y": "visits", "data": [{"month": "Jan", "visits": 120}, {"month": "Feb", "visits": 150}]}
```
````

`type` is `line` (the default), `area`, `bar` or `scatter`. Other options: `series` (a column to split lines by), `average` (a trailing mean, as a count like `7` or a window like `"7d"`), `lines` (reference lines), `stacked`, `points`, `yMin`, `yMax`, `format` and `height`.

An editable database:

````markdown
```database
{"columns": [{"name": "Task", "type": "text"}, {"name": "Done", "type": "checkbox"}], "rows": [{"Task": "Write docs", "Done": "false"}]}
```
````

Edits in the grid are written back into the block's JSON. A `{"pk": "…"}` body points at a database kept by the app instead.

A sortable table:

````markdown
```datatable
[{"Item": "Hosting", "Cost": 12}, {"Item": "Domain", "Cost": 1.5}]
```
````

## Mermaid

Every diagram type in mermaid 11 works, including the newer ones (architecture, packet, radar, treemap, kanban). Those newer types care about indentation, so write their source flush-left. A diagram that doesn't parse shows the error instead of breaking the note.

## Next steps

- [The editor](editor.md)
- [Slash menu](slash-menu.md): inserting these blocks
- [Dictation and recordings](../guides/dictation-and-recordings.md)
