Import/export & sharing
URL sharing
Your automaton is automatically encoded in the URL hash on every change. The encoding includes all state positions, labels, flags (initial/accepting), transitions with symbols, and the current mode. Press ⌘S or click SHARE to copy the full URL to clipboard. Anyone opening the URL will see your exact automaton with identical layout.
JSON export
Press ⌘E to download your automaton as a JSON file. The format is:
→ _format: "stateforge-v1" — format identifier
→ mode — automaton type (dfa, nfa, pda, tm, mealy, moore)
→ states — array of state objects with id, label, x, y, isInitial, isAccepting
→ transitions — array of transition objects with id, from, to, symbols array
→ File is named stateforge-MODE.json (e.g., stateforge-dfa.json)
PNG export
Export your automaton as a PNG image at 2x resolution (retina). The export captures all states and transitions with proper padding, rendered against a dark background. The canvas grid is excluded. Access via the command palette (⌘K then "Export PNG") or the toolbar export menu.
→ File is named stateforge-MODE.png (e.g., stateforge-dfa.png)
SVG export
Export as a standalone SVG file with all CSS custom properties inlined as actual color values. The SVG includes embedded font declarations and a dark background, so it renders correctly in any viewer without needing StateForge's stylesheet.
→ Grid pattern is removed for a clean export
→ File is named stateforge-MODE.svg
Copy as LaTeX/TikZ
Copy your automaton as a tikzpicture environment using the tikz-automata format. State positions are scaled from pixels to centimeters (50px = 1cm), with the Y axis flipped for LaTeX conventions.
→ States include initial and accepting options as appropriate
→ State labels are formatted as $q_{n}$ for standard q-labels
→ Bidirectional transitions use bend left to avoid overlap
→ Self-loops render with loop above
→ Access via toolbar export menu or command palette
Import
Press ⌘O to import a file. Supported formats:
→ .json — StateForge native format. Must have a states array. Mode defaults to "dfa" if not specified.
→ .jff — JFLAP XML format. The importer parses the XML structure to extract states (with coordinates), transitions (with read/write/pop/push/move attributes), and automaton type (fa→dfa, pda→pda, turing→tm). State positions are preserved from the JFLAP file.
After import, Zoom to Fit is automatically called to frame the loaded automaton. The next state number counter is set to one past the highest existing qN label.
Auto-Save
Your work is automatically saved to localStorage via Zustand's subscription mechanism. On reload, it restores your last automaton (states, transitions, mode, viewport). The URL hash takes priority over localStorage if present, so opening a shared link always loads that specific automaton regardless of what was saved locally.