CLI
Preview version
The jsmind CLI is currently a preview. Commands and options will change in later updates. Please check this page for the commands that are current.
The CLI is the command-line interface for jsMind V2 map data. You can create a map, inspect its tree and ids, change structure and node attributes, validate a file, and export an image or a page that opens offline.
Install
Install the 2.x version with npm i jsmind@2, then run npx jsmind. From a clone of this repository, build first and run npx jsmind or node dist/cli.js. These are alternatives: pick one, not both. See Getting Started for install details.
For a one-shot reminder of the flags, jsmind --help prints the built-in help. This page is the documentation to consult for the commands that are current in the preview.
Usage
jsmind <command> [options]Global options
These options are accepted by every command and subcommand.
| Option | Meaning | Version |
|---|---|---|
--json | Machine-readable output | — |
--strict | Treat an unknown option as a usage error | Since: 2.1.0 |
--version | Print the version and exit | Since: 2.1.0 |
-h, --help | Show the built-in help | — |
Write options
These three describe a write — where it lands, and whether it happens — so only the commands that write accept them: create, and the mind and node subcommands that write. validate, context and export report them as unknown options instead, and so do the read-only mind find and mind list-edges.
| Option | Meaning | Version |
|---|---|---|
--dry-run | Show what would change, write nothing | — |
--output <path> | Write somewhere other than the input file | — |
--backup | Keep a .bak copy before overwriting | — |
--output belongs only to the mind and node subcommands that write: create and export take their output path as a positional argument, so create x.json --output y.json is reported as an unknown option rather than quietly ignored.
Every other option belongs to a specific subcommand; the sections below list them. An option a command does not take is reported instead of being ignored — see Unknown options.
--version prints the version string from package.json, on its own line and with nothing else, and needs no command. The version is defined in one place only, so it cannot fall behind a release.
Unknown options
Each subcommand accepts a fixed set of options: the global ones above plus its own. An option outside that set — a misspelt flag, or one that belongs to a different subcommand — is reported on stderr, and the command still runs.
$ jsmind mind find map.json --node-id root --sdie
jsmind: warning: unknown option for "mind find": --sdie (--strict makes this an error)
{
"id": "root",
...
}The warning never goes to stdout, so --json output stays parseable. The other side of that choice: a consumer that reads only stdout and the exit code does not see the warning. That is the cost of warning instead of failing, not a defect to be fixed later. When that blind spot matters, add --strict, which turns the same call into a usage error with exit code 2:
$ jsmind mind find map.json --node-id root --sdie --strict
Unknown option for "mind find": --sdie
$ echo $?
2Pass --strict in scripts and agent workflows, where a silently ignored flag is worse than a failed run.
There is no spelling suggestion. Deciding that --sdie "looks like" --side means guessing at intent, and a wrong guess sends you to fix a flag you never typed.
Exit codes
| Code | Meaning |
|---|---|
0 | Success |
1 | Invalid data |
2 | Usage error |
3 | IO or runtime error |
create
jsmind create <file> --title <title> [options]Start a new mind map containing a single root node.
| Option | Meaning |
|---|---|
--title <title> | Root node label; also becomes meta.name (required) |
--name <name> | Override meta.name when it should differ from the title |
--author <author> | Author recorded in meta |
--force | Overwrite the file if it already exists |
--backup | Keep a .bak copy of the file being overwritten |
--dry-run | Print the document instead of writing it |
--json | Print {file, rootNodeId} instead of the confirmation line (Since: 2.2.0) |
create refuses to overwrite an existing file without --force. Every other command assumes a file already exists; this is where one comes from.
validate
jsmind validate <file> [--json]Checks a v2 mind map file against the format specification and reports every problem found. It does not modify the file.
| Exit code | Meaning |
|---|---|
0 | Valid |
1 | Invalid data |
3 | The file cannot be read |
context
jsmind context <file> [options]Discovery step: shows the tree so you (or an agent) can find the ids needed for later commands.
| Option | Meaning |
|---|---|
--highlight <text> | Match a label (case-insensitive) and print its id path; repeatable (Since: 2.2.0) |
--depth <n> | Levels below the root to show (default 2) |
--max-text <n> | Truncate labels at n characters (default 40) |
--full-text | Do not truncate |
--ids-only | Print ids only |
--json | Machine-readable output |
Ids are printed in a left-aligned column so they can be copied into the next command. Multi-line labels are flattened, and truncation ends in an ellipsis. Each line may end with a {…} block. side is shown only for the root and the root's direct children. folded appears when the node is collapsed, and style overrides appear when the node differs from the theme.
--highlight covers the step where the label is already known and only the id is missing: the whole label is compared, ignoring case, against the printed label (not the truncated form, no fuzzy matching), across the whole document rather than just the levels --depth shows. A hit is listed first as "text" -> "root"/"id"; a miss prints (no match) instead of a guess or a candidate list. A label carried by more than one node resolves to the first in document order and is marked (+N more). --highlight also refuses --ids-only in text mode: --ids-only prints one bare id per line, --highlight prints an id path per label, and the block cannot sit inside that shape. Add --json to get the highlighted ids without the labels.
A file that declares its own document style is announced above the tree, so the theme is discoverable before any node is read (Since: 2.1.0):
style: theme=default defaultTone=primary overrides=defaultTone,tones,node--json returns an object with a nodes array, where every node carries parentId (null on the root), so the parent-child relation does not have to be inferred from the order of level (Since: 2.2.0). With --highlight it also carries a highlighted block first, whose hits have the same shape as a node in nodes and whose misses keep their key with null. Same shape, not necessarily the same entry: a label found below --depth is not listed under nodes, and a shared label adds a matches count. It adds the same summary as a top-level style block (theme, defaultTone, overrides) when the file carries one. Neither appears for a file with no document style, and the text line is suppressed under --ids-only.
export
jsmind export image <file> <out.png> [options]
jsmind export html <file> [out.html] [options]export is a group, and the word after it names what to produce: image renders a picture, html writes one page that opens offline. jsmind export --help lists both, each with the options it takes. The kind is not optional — a bare jsmind export <file> <out.png> is an argument error (2) rather than an image export with the kind guessed.
export image
Renders a mind map to an image. The size is the map's own size: whitespace inside the viewport is kept, and a map larger than the viewport is not cropped.
export image requires a Chromium browser. Set CHROME_PATH if it is not in a standard location, and JSMIND_BROWSER_START_MS (Since: 2.1.0) if the browser needs longer than the default 60 seconds to start.
Rendering happens inside a browser process, so an execution environment that sandboxes child processes may ask for permission — or offer to leave the sandbox — when export image runs. That is Chromium starting, not a failure; if it asks every time, put the output directory on the environment's allow-list.
The output file is overwritten in place: an existing image at that path is rewritten, with no copy kept and no delete first. To keep the old one, give the second positional a different path, or rename the old file first — note that --output belongs to the commands that edit a mind map file, and export image only reads its output path from the second positional.
| Option | Meaning | Version |
|---|---|---|
--width <px> | Viewport width to lay the map out in (default 1200) | — |
--height <px> | Viewport height (default 800) | — |
--scale <n> | Output pixel ratio (default 2) | — |
--type <format> | png, jpeg, or webp (default png); jpg is accepted as another spelling of jpeg | — |
--transparent | Transparent background (PNG and WebP; opt-in, default keeps the current opaque background). For JPEG, the option is ignored and a warning is printed. | Since: 2.1.0 |
--json | Machine-readable output | — |
--type chooses the encoding, not the file name: the bytes are the format it names, and the output path is written exactly as given. When the two disagree — out.png --type jpeg — the export still runs, with one warning on stderr and exit code 0: some artifacts are named for the tool that consumes them, so neither side is overridden. The comparison reads the extension only (.png, .jpg / .jpeg, .webp), and an extension that names no image format is not compared at all.
With the default width, height, and scale, a typical export is 2400×1600 pixels.
export html
Writes one .html file and nothing beside it: the renderer, the shell and the map are inlined, so the page opens from a file:// URL on a machine with no network. No browser is started to write it — that is the difference from image, which needs one to produce its bytes (Since: 2.3.0).
The output path is optional. Without it the page takes the input's name with an .html extension, so map.json becomes map.html.
The map is kept in the page as text, in a <script type="application/json"> block, so anything that can read the file can read the map back out of it — an agent does not need a browser to see what the page contains. Nothing in the file points anywhere else: no stylesheet, no script, no image, no CDN.
A map larger than the window opens at the size its text was written for, so part of it is off the edge; the page itself never scrolls. Dragging, the wheel and a double-click on the canvas move the map's own viewport, and the double-click also fits the whole map into the window. A toolbar in the corner repeats the fit and the zoom with buttons, and exports the whole map - not just the part on screen - as a PNG. The page also tells whoever receives the file how to install the skill that lets an agent edit it.
| Option | Meaning | Version |
|---|---|---|
--title <text> | The page's <title>. Defaults to the map's meta.name, then to the file name | Since: 2.3.0 |
--json | Machine-readable output: {"file": …, "output": …} | Since: 2.3.0 |
mind
jsmind mind <subcommand> <file> [options]Structure, edges, and the document's style. Locators are ids only. Use ids from a current context output; do not reuse ids copied from examples.
| Subcommand | Options | Meaning | Version |
|---|---|---|---|
find | --node-id <id> | Show one node | — |
list-edges | --node-id <id> | Edges touching a node | — |
add-child | --parent-id <id> --text <text> [--side left|right] [--position <n>] [--folded true|false] | Add a child node | — |
move | --node-id <id> --parent-id <id> [--position <n>] | Reparent a node | — |
remove-node | --node-id <id> | Remove the node, its whole subtree, and every edge touching any of them | — |
add-edge | --source-id <id> --target-id <id> [--type link] [--label <text>] | Add a relation | — |
remove-edge | --edge-id <id> | Remove a relation | — |
set-style | --default-tone <tone> | The document's style (mind.style): the tone untoned nodes wear | Since: 2.1.0 |
Every mutating subcommand validates the result and rolls back on failure. --dry-run, --output, and --backup are available on these writes.
mind find
jsmind mind find <file> --node-id <id>Show one node: its id, label, parent, the ids of its children, and its side. Read-only — it goes through no write pipeline, so the write options above do not apply.
--node-id is required. The output is JSON whether or not --json is given: parent is null on the root, folded: true appears only when the node is collapsed, and a style block appears only when the node overrides the theme. An id that is not in the file is an invalid-data error (1), not a usage error.
mind list-edges
jsmind mind list-edges <file> --node-id <id>List every edge that touches the node, as source or as target. Read-only, like find: no write pipeline, and the write options above do not apply.
--node-id is required. The output is a JSON array of {id, source, target, type, label}, printed with or without --json — label is null when the edge carries none, and a node with no edges prints []. These are the ids remove-edge takes. A node id that is not in the file is an invalid-data error (1).
mind add-child
jsmind mind add-child <file> --parent-id <id> --text <text> [--side left|right] [--position <n>] [--folded true|false]Add a new child under an existing node. --parent-id and --text are required, and an empty --text counts as missing (usage error).
--side applies only when the parent is the root node. A side is the placement of a root child, and every node below one inherits it, so a side written deeper would change the file and not the picture — that is a usage error naming the first-level branch, not a silent no-op. Only the root is center, so --side takes left or right.
--position is a non-negative index into the parent's children array. A value at or past the end appends, and omitting it appends too. The root's children are counted across both sides: the index addresses that one array, not one side's list.
--folded true creates the node collapsed; leaving the flag out creates it unfolded. The confirmation line repeats the side and the folded state when they were given.
mind move
jsmind mind move <file> --node-id <id> --parent-id <id> [--position <n>]Reparent a node, or reorder it among its siblings when --parent-id is already its parent. --node-id and --parent-id are required; --position takes the same children-array index as add-child.
A move into the node's own subtree is refused as invalid data (1): naming the node as its own parent, or a parent that is one of its descendants, fails with both ids in the message. The root cannot be moved — every other node is its descendant.
mind remove-node
jsmind mind remove-node <file> --node-id <id>Remove a node and its whole subtree, plus every edge touching any node in that subtree. --node-id is required.
The root is refused: removing it is an invalid-data error (1) naming the node and the file, and nothing is written.
mind add-edge
jsmind mind add-edge <file> --source-id <id> --target-id <id> [--type link] [--label <text>]Add a relation between two existing nodes, independent of the parent-child tree. --source-id and --target-id are required, and both endpoints must be in the file — an id that is not is an invalid-data error (1) naming which end it was.
--type takes link today: the only value the format defines, and the default. Any other word is not refused before the write — the post-write validation rejects it (Unknown edge type, exit 1) and the file is rolled back, so the edge never lands.
--label is optional; without it the edge carries no label. The command prints the new edge id, which is also what list-edges reports for it.
mind remove-edge
jsmind mind remove-edge <file> --edge-id <id>Remove one relation by id; the nodes at its ends stay. --edge-id is required, and its value comes from list-edges output — an edge has an id of its own, not one of the node ids context prints.
An id that is not in the file is an invalid-data error (1). The command reports the edge id it removed.
mind set-style
jsmind mind set-style <file> [style fields]The document's style (mind.style): one declaration every node without an override inherits. It writes mind.style, not a node's style — overriding the theme for one node is node set-style — so a whole-map recolour stays one write, and leaves the semantic tones free for the nodes that need to stand out.
| Field | Accepted values |
|---|---|
--default-tone <tone> | default | primary | success | warning | danger | info | accent |
defaultTone is the tone an untoned node wears. Precedence is node.style.tone over mind.style.defaultTone over "default", and lines follow the same fallback. The field stores a tone name, not a palette, so a tones override keeps applying to it.
--dry-run, --output, and --backup work as on every other mutating command.
node
jsmind node <subcommand> <file> --node-id <id> [options]Node attributes. Structure changes go through jsmind mind.
| Subcommand | Options | Meaning |
|---|---|---|
set-text | --node-id <id> --text <text> | Change the label |
set-folded | --node-id <id> --folded true|false | Collapse or expand |
set-side | --node-id <id> --side left|right | Set the node's side |
set-style | --node-id <id> [style fields] | Override the theme for one node |
Node id, parent, and children are changed only through jsmind mind. Every node subcommand validates the result and rolls back on failure. --dry-run, --output, and --backup are available on these writes.
node set-text
jsmind node set-text <file> --node-id <id> --text <text>Change one node's label. --node-id and --text are both required, and an empty --text counts as missing (usage error). A node id that is not in the file is an invalid-data error (1).
node set-folded
jsmind node set-folded <file> --node-id <id> --folded true|falseCollapse or expand one node. --folded is required and takes only the words true and false — there is no --no-folded, and anything else is a usage error (2) naming the flag. --node-id is required.
node set-side
jsmind node set-side <file> --node-id <id> --side left|rightPlace a direct child of the root on the other side. --node-id and --side are required, and --side takes left or right: center is the root's own state and is refused as a usage error.
It accepts only a direct child of the root, for the same reason as add-child --side — those are the only nodes whose side moves anything, and every node below one inherits it. The root itself is a usage error (2) because it is always center, and so is a deeper node: that message names the first-level branch and points at the node whose side actually carries the change.
node set-style
jsmind node set-style <file> --node-id <id> [style fields]Override the theme for one node (node.style); the document-wide default these fall back to is mind set-style. Fields can be combined in one write. A dot marks a level, so --incoming.color addresses style.incoming.color.
| Field | Accepted values |
|---|---|
--tone <value> | default | primary | success | warning | danger | info | accent |
--background <color> | A CSS color string |
--color <color> | A CSS color string |
--border-color <color> | A CSS color string |
--border-width <number> | A positive number |
--border-style <value> | solid | dashed | dotted |
--font-size <number> | A positive number |
--font-weight <value> | normal | bold |
--incoming.color <color> | A CSS color string |
--incoming.width <number> | A positive number |
--incoming.pattern <value> | solid | dashed | dotted |
--incoming.curve <value> | straight | bezier |
To restore the theme's value:
| Option | Meaning |
|---|---|
--clear <fields> | Comma-separated field names in the flag spelling or the file's camelCase (font-size or fontSize) |
--reset | Drop every override on this node |
A style block records only what differs from the theme, so removing a key restores the theme's value. There is no unset sentinel — an absent key means an absent override. --reset cannot be combined with fields or --clear.
At least one field, --clear, or --reset is required: called with none of them, it is a usage error (2) that lists the fields. A name --clear does not know is a usage error listing the ones it accepts.
Colors are not checked beyond being strings; the theme accepts any CSS color. Tones, patterns, and weights are checked so a bad value names the flag you typed rather than a JSON path.
See also
- Getting Started — install and create a first map
- Skill — guardrails for an agent that draws or edits a map with this CLI