SmarkForm
SmarkForm turns annotated HTML into a component tree whose fields, nested forms, and lists import and export structured JavaScript objects and arrays.
π Autoplays muted β unmute it (π in the player controls) to hear the narration.
How SmarkForm works
Keep your HTML and CSS. Add data-smark to the elements SmarkForm should manage, then initialize the root:
<div id="profile">
<input data-smark name="name" value="Ada">
<fieldset data-smark='{"type":"form","name":"address"}'>
<input data-smark name="city" value="Barcelona">
</fieldset>
<ul data-smark='{"type":"list","name":"phones"}'>
<li><input data-smark name="number" value="+34 600 000 000"></li>
</ul>
</div>
<script>
new SmarkForm(document.getElementById("profile"));
</script>
That markup describes a component tree. Exporting the root returns ordinary structured data:
{
"name": "Ada",
"address": { "city": "Barcelona" },
"phones": [{ "number": "+34 600 000 000" }]
}
Named fields become object properties, each list item template becomes an array element, and forms and lists can nest to any depth. SmarkForm does not render a schema or take over your application: you still own the markup, styles, semantics, validation, and submission policy.
Try the interactive demo
A nested subform, a sortable list, context-driven hotkeys, and date/time coercion β all driven by data-smark attributes. Switch between the HTML, CSS, JavaScript, and preview tabs, then export the result as JSON.
<div id="myForm">
<div class="ep">
<p>
<label data-smark>π Event:</label>
<input data-smark name="title" type="text" placeholder="e.g. Sprint Review">
</p>
<p>
<label data-smark>π
Date:</label>
<input data-smark name="date" type="date">
</p>
<p>
<label data-smark>β° Time:</label>
<input data-smark name="time" type="time">
</p>
<fieldset data-smark='{"type":"form","name":"organizer"}'>
<legend data-smark='label'>π€ Organizer</legend>
<p>
<label data-smark>Name:</label>
<input data-smark name="name" type="text">
</p>
<p>
<label data-smark>Email:</label>
<input data-smark name="email" type="email">
</p>
</fieldset>
<div class="ep-list">
<button data-smark='{"action":"removeItem","context":"attendees","hotkey":"Delete","preserve_non_empty":true}' title='Remove empty slots'>π§Ή</button>
<button data-smark='{"action":"addItem","context":"attendees","hotkey":"+"}' title='Add attendee'>β</button>
<strong data-smark='label'>π₯ Attendees:</strong>
<ul data-smark='{"type":"list","name":"attendees","sortable":true,"export_empties":false}'>
<li>
<details>
<summary>
<span data-smark-type="label" class="bullet">
<span data-smark-action="position">N</span> β°
</span>
<input data-smark type="text" name="name" placeholder="Name">
<button data-smark='{"action":"removeItem","hotkey":"-"}' title='Remove'>β</button>
<button data-smark='{"action":"addItem","hotkey":"+"}' title='Insert here'>β</button>
</summary>
<div class="ep-attendee-details">
<input data-smark type="email" name="email" placeholder="Email">
<input data-smark type="tel" name="phone" placeholder="Phone">
</div>
</details>
</li>
</ul>
</div>
<p class="ep-hint">π‘ Hold <kbd>Ctrl</kbd> to reveal shortcuts</p>
</div>
</div>
#myForm .ep {
display: flex;
flex-direction: column;
gap: 0.35em;
max-width: 460px;
font-size: 0.95em;
}
#myForm .ep p {
display: flex;
align-items: center;
gap: 0.5em;
margin: 0;
}
#myForm .ep label {
font-weight: 500;
white-space: nowrap;
}
#myForm .ep label:not(.bullet) {
min-width: 4.5em;
}
#myForm .ep input {
padding: 0.3em 0.5em;
border: 1px solid #ccc;
border-radius: 4px;
}
#myForm .ep input[type="text"],
#myForm .ep input[type="email"] { flex: 1; }
#myForm .ep fieldset {
border: 1px solid #ddd;
border-radius: 6px;
padding: 0.4em 0.8em 0.6em;
margin: 0;
display: flex;
flex-direction: column;
gap: 0.3em;
}
#myForm .ep fieldset legend { font-weight: bold; padding: 0 0.3em; }
#myForm .ep-list ul {
list-style: none;
padding: 0;
margin: 0.2em 0 0;
display: flex;
flex-direction: column;
gap: 0.25em;
}
#myForm .ep-list ul li { display: flex; align-items: flex-start; gap: 0.3em; }
#myForm .ep-list ul li details {
width: 100%;
border: 1px solid transparent;
border-radius: 4px;
transition: border-color 0.15s;
}
#myForm .ep-list ul li details[open] {
border-color: #ccc;
padding-bottom: 4px;
}
#myForm .ep-list ul li summary {
display: flex;
align-items: center;
gap: 0.4em;
cursor: default;
user-select: none;
padding: 0.1em 0.2em;
list-style: none;
}
#myForm .ep-attendee-details {
display: flex;
flex-wrap: wrap;
gap: 0.4em;
padding: 0.35em 0.4em 0.1em 1.5em;
}
#myForm .ep-attendee-details input { flex: 1; min-width: 120px; }
#myForm .ep-hint {
font-size: 0.82em;
color: #888;
margin: 0.15em 0 0;
}
#myForm .ep-hint kbd {
background: #f4f4f4;
border: 1px solid #ccc;
border-radius: 3px;
padding: 1px 4px;
}
/* Hotkey hints revealed on Ctrl press */
#myForm [data-hotkey]{position:relative}
#myForm [data-hotkey]::after{
content:"Ctrl+" attr(data-hotkey);
position:absolute; top:0.75em; left:0;
font-size:0.7em;
background:#333; color:#fff;
padding:1px 4px; border-radius:3px;
white-space:nowrap;
}
/* Attendee list item entry/exit animations */
#myForm .ep-list ul li.animated_item {
transform: translateX(-100%);
opacity: 0;
transition: transform 200ms ease, opacity 200ms ease;
}
#myForm .ep-list ul li.animated_item.ongoing {
transform: translateX(0);
opacity: 1;
}
const myForm = new SmarkForm(document.getElementById("myForm"), {
"value": {
"title": "Sprint Review",
"date": "2025-03-15",
"time": "10:00:00",
"organizer": {
"name": "Alice Johnson",
"email": "alice@example.com"
},
"attendees": [
{"name": "Bob Smith", "email": "bob@example.com", "phone": "+1 555 200 0001"},
{"name": "Carol White", "email": "carol@example.com", "phone": "+1 555 200 0002"},
{"name": "Dave Brown", "email": "dave@example.com", "phone": "+1 555 200 0003"}
]
}
});const delay = ms=>new Promise(resolve=>setTimeout(resolve, ms));
myForm.onAll("afterRender", async function(ev) {
if (ev.context.parent?.options.type !== "list") return;
const item = ev.context.targetNode;
item.classList.add("animated_item");
await delay(1);
item.classList.add("ongoing");
});
myForm.onAll("beforeUnrender", async function(ev) {
if (ev.context.parent?.options.type !== "list") return;
const item = ev.context.targetNode;
item.classList.remove("ongoing");
await delay(150);
});
What you get
The core model
- Your HTML and CSS stay yours: Mark elements; do not hand over the layout.
- Nested forms: Forms are fields that export objects and can nest to any depth.
- Variable-length lists: Lists export arrays, grow and shrink at runtime, and support drag-and-drop sorting.
- JSON import and export: Move structured data in and out of the whole form or any single field.
Developer experience
- Declarative actions and context: Triggers find their fields from their position in the form tree.
- Context-driven hotkeys: Keyboard shortcuts are scoped to where the user is working.
- Consistent keyboard navigation: Enter/Shift+Enter move between fields; controls stay reachable.
- Path-based addressing: Address fields by form structure, not DOM position.
Additional capabilities
- Lightweight and dependency-free: One library, no runtime dependencies, ESM and UMD builds.
- Accessibility support: Label wiring and keyboard behavior, with the remaining author responsibilities stated clearly.
- Media fields: File, image, video, and audio fields share the same value model.
- AI-agent resources: Optional agent guidance for generating forms from a description.
Start where you are
See it
- Showcase β interactive examples at a glance.
- Downloadable examples β run and edit them locally.
- Playground β experiment in the browser.
Use it now
- Quick Start β make a form and export a useful value.
- Getting SmarkForm β CDN, npm, and downloaded copies.
- Core Concepts β the component tree and data model.
- Using SmarkForm β the fuller developer walkthrough.
Go deeper
- Guides β tasks such as import/export, traversing, events, and mixins.
- Component Reference β type-specific options and edge cases.
- Developer Cheatsheet β a compact implementation reference.
Decide whether it fits
- Introduction β what SmarkForm is and is not.
- When SmarkForm Fits β a neutral comparison of approaches.
- FAQ β common questions and edge cases.
Current Status
SmarkForm is stable and in active use, but still pre-1.0: implemented behavior is covered by tests, while the public API may evolve before 1.0.0. Not every initially planned feature is implemented; see the Roadmap for what is planned and what is not.
Last Updated: Sun Nov 15 2026.
Community and Support
If you donβt find a solution in the documentation, feel free to open a discussion on our GitHub repository.
For further support, you can contact me through our Contact Page or reach out via email at smarkform@bitifet.net.
If you want to stay updated with the latest news, releases, and announcements, or join the community chat, you can follow us on Telegram:
π Stay tuned
Contributing
We welcome feedback, suggestions, and improvements as we continue to enhance and expand SmarkForm.
π See the Contributing section for more details.