Skip to content

Saving & Loading

ZXW Graphboard is a client-side app: there is no server-side storage. Your work is kept in two ways — automatic saving to your browser, and manual export/import of files for sharing and backup.

As you edit, the workspace is automatically saved to your browser’s localStorage about 2 seconds after each change — including adding, renaming, or closing tabs, and switching between them. The next time you open the editor (in the same browser), every tab is restored exactly as you left it — each graph with its positions and rotations, and the tab you had active back on screen.

  • The storage key is graph-board-document.
  • Only the most recent workspace is kept; there is no history of past saves.
  • Clearing your browser data (or site storage) erases the saved workspace. Use export for anything you want to keep long-term.

⌘/Ctrl + S, or the Save toolbar button, writes the current workspace (all tabs) to localStorage immediately (no file dialog). This is the same mechanism as autosave, just without the 2-second debounce.

The Export toolbar button opens an export-format dialog where you pick a format, then writes the active tab’s graph to a file on disk — other tabs are not included:

  • JSON (.json) — implemented. The native Graph Board document format (graph + view slices). Node positions are mean-centered before export, so the file doesn’t carry absolute canvas offsets and diffs cleanly between sessions.
  • TikZ (.tikz) — implemented. A LaTeX tikzpicture (ZX style definitions + nodes/edges) — see below for using it in LaTeX.
  • Graph3 (.graph3) — implemented. The plain-text multigraph format — see Graph3 Format. Export is the inverse of import: black dots, H, and X/Z spiders with phases in π/4 steps are written as typed declarations (parallel edges are consolidated into one multiplicity line), and anything the format cannot express is skipped and listed in a # skipped ... header comment.
  • ZXLive, QASM — placeholders for future exporters; they currently produce a marked placeholder file, not real output.

For JSON export:

  • Browsers with the File System Access API (Chrome, Edge, other Chromium) show a native save dialog and can overwrite a previously saved file in place.
  • Other browsers (e.g. Firefox, Safari) download the file normally.

The exported file’s name is derived from the active tab’s name, sanitised into a safe filename (unsafe characters stripped). Documents carry createdAt/updatedAt timestamps, and JSON export preserves the original creation time — re-exporting a graph doesn’t stamp a new creation date. The JSON contains the full graph with a stable shape described in the developer docs — you can safely version-control it, diff it, or process it with other tooling.

A TikZ export is a standalone picture file: a self-contained \begingroup … \endgroup block with the ZX styles, layers, nodes, and edges all included. It is meant to be \input from your document, not edited by hand.

Your LaTeX preamble needs the following:

\usepackage{tikz}
\usepackage{graphicx} % only needed for \resizebox
\usetikzlibrary{shapes, shapes.misc, shapes.geometric, arrows.meta, positioning}

Import the picture inside a figure, scaling it to your layout:

\begin{figure}
\centering
\resizebox{1.5\linewidth}{!}{%
\input{<filename>.tikz}%
}
\end{figure}
  • The file defines its own colors with \providecolor, so it works even when a color is already defined elsewhere in your document.
  • graphicx (and the \resizebox wrapper) is only needed if you want to scale the picture; drop both to include it at its natural size.
  • All vertex types are styled; spider phases are emitted as math (e.g. $\pi$).

The Import toolbar button opens a file picker and merges the saved graph into the tab you are currently working in — nothing is replaced, and other tabs are untouched.

  • The imported graph is placed around the centre of your current view (plus a small offset), so it appears where you are looking.
  • Imported vertices and edges are selected afterwards, so you can immediately see — and move, copy, or delete — what was added.
  • If an imported vertex or edge id collides with one already in your graph, the imported id is automatically changed to a fresh one; your existing vertices stay untouched (their connected edges keep pointing at them).
  • Edges whose endpoints aren’t among the file’s vertices are dropped — importing them would leave dangling references.
  • Import is non-destructive and can be undone: the merge is one step on the undo history, so ⌘/Ctrl+Z removes the imported graph.
  • Malformed or future-version files are rejected with a readable error; a file whose node/edge elements are structurally broken is refused with a message instead of crashing the editor.

The Import .graph3 toolbar button reads a Graph3 file — a plain-text graph format where each line declares vertices, parallel edges between them, and an optional vertex/edge type (1 : Z(3), 2 3 : H). See Graph3 Format for the full specification.

  • Vertices are imported according to their declared type — black dot by default, a Hadamard box for H, or an X/Z spider with phase n·π/4 for X(n) / Z(n) — and placed around the centre of your view on a circle.
  • A two-number line is one edge; a three-number line a b c is c parallel edges. NC edges import as default-kind edges; Hadamard (H) edges import as dashed-blue edges.
  • Like JSON import, it merges into the active tab (nothing is replaced) and selects the imported elements.

The red Reset button (top-right of the toolbar, octagon icon) clears the active tab’s graph — all nodes and edges in that tab — and saves the emptied tab. Other tabs are untouched, the tab keeps its name, and the shared clipboard survives. You confirm first, and reset cannot be undone (it clears that tab’s undo history). Use it for a genuinely blank canvas.