A small, browser-based visual editor that lets you build and manipulate a JSON-based layout model by directly interacting with rendered DOM nodes.
The editor renders a JSON structure as absolutely positioned elements, allows selection, dragging, zooming and panning, and keeps the JSON model in sync in real time.
- Visual rendering of a JSON layout model
- Click to select elements
- Drag elements to reposition them
- Zoom and pan the editor canvas
- Add and remove child nodes
- Inspector panel for editing selected element properties
- Inline text editing for content-editable nodes
- Live JSON output preview
- Persist model in
localStorage - Import JSON via drag & drop or paste
.
├── index.html
├── css/
│ ├── editor.css # Editor canvas & selection styling
│ ├── inspector.css # Inspector panel styling
│ ├── toolbar.css # Toolbar layout
│ └── output.css # JSON output panel styling
└── js/
├── app.js # App bootstrap, state, persistence
├── renderer.js # Render JSON nodes into DOM
├── interaction.js # Selection and dragging logic
├── selection.js # Selection state handling
├── inspector.js # Inspector UI & property editing
├── model.js # JSON model manipulation helpers
├── styles.js # Apply JSON-defined styles to DOM
├── toolbar.js # UI toolbar actions
└── viewport.js # Zoom & pan behavior
The editor operates on a single JSON object (MODEL) with this general shape:
{
content: {
id: "root",
pt: { left: 10, top: 10, width: 100, height: 40 },
no: { position: "absolute" },
content: "Hello"
},
classList: {
// optional shared styles
}
}Key concepts:
contentcan be:- a string (text)
- a single child node
- an array of child nodes
pt= positional / dimensional styles (numbers → px)no= non-positional stylescls= reference to shared styles inMODEL.classList
- Each node is rendered as a
<div class="node"> - All nodes are positioned absolutely by default
- Styles are derived from JSON via
styles.js - Nested content produces nested DOM elements
- Each DOM node keeps a reference to its JSON node via
el.__node
- Click a node to select it
- Drag a node to update its
pt.left/pt.top - Scroll to zoom the canvas
- Space + drag to pan the canvas
- Edit text if
contenteditableis enabled on the node - Selection state is reflected visually with an editor-style outline
The Inspector panel displays and edits properties of the currently selected element.
Currently editable:
id- Position:
left,top - Size:
width,height - Text content (for string-based nodes)
All changes update the JSON model immediately and trigger a re-render.
The bottom toolbar allows you to:
- ➕ Add a child node to the selected element
- 🗑 Remove the selected node (if removable)
- See live selection status
- The model is automatically saved to
localStorage - Reloading the page restores the last state
- You can:
- Drag & drop a
.jsonfile onto the page - Paste valid JSON from the clipboard
- Drag & drop a
- A Clear button resets the model and storage
No build step required.
Just open index.html in a modern browser:
open index.htmlOr serve it via a simple local server if needed.
This project is currently a prototype / experimental editor.
Things not yet implemented:
- Schema validation
- Undo / redo
- Keyboard shortcuts
- Resizable elements
- Export / import UI (beyond drag & paste)
- Define a formal JSON schema
- Add resize handles
- Improve class/style management UI
- Add keyboard navigation
- Export rendered HTML/CSS
Unlicensed / experimental — do whatever you want with it.