1. What is json-renderers?
json-renderers is the browser runtime layer in the KeshavSoft declarative UI ecosystem. It accepts render configuration, obtains a JSON description of the requested component, asks @keshavsoft/json-to-tag to create DOM nodes, and mounts the result in the requested browser container.
It is an orchestration layer rather than the specification compiler itself. The component structure is prepared upstream by json-renderers-build; actual element construction is delegated to @keshavsoft/json-to-tag.
Rows, option values, component type, target element ID, and optional columns.
The builder assembles the declarative JSON structure for the selected component.
Real browser elements appear inside the target container.
2. A simple story everyone can understand
Imagine we are building a house. The same idea helps explain how a UI becomes real HTML on a webpage.
The architect prepares a blueprint. Here, it prepares the JSON structure in the format that the next tool expects.
The worker reads the blueprint and builds the actual parts. Here, it converts the JSON specification into real HTML DOM elements.
The manager takes the built parts to the right place. Here, it mounts the created elements inside the target container on the webpage.
Example: displaying a student table
-
We provide student data.
For example: student names and their cities, plus the ID of the HTML container. -
The architect prepares the blueprint.
json-renderers-buildproduces a JSON specification describing the table. -
The construction worker builds the table elements.
json-to-tagreads that specification and creates the HTML DOM elements. -
The site manager puts the table in place.
json-renderersmounts the result inside the target HTML container, so the user can see the table.
json-renderers-build prepares the
blueprint, json-to-tag builds the actual DOM elements, and json-renderers places
them on the webpage.3. Architecture and rendering pipeline
The README describes the flow from application inputs to the final browser DOM as a staged pipeline:
Pass a component type, data, columns, and target HTML ID.
Builds a declarative JSON specification for the component.
Converts the specification into browser DOM nodes.
Mounts the result into the specified container.
-
The application calls the render function.
The configuration includes values such astype,targetHtmlId,data, and optionallycolumns. -
The builder prepares the component specification.
Thejson-renderers-buildpackage combines the component blueprint with the supplied data and returns a JSON spec. -
The JSON spec is converted into DOM.
@keshavsoft/json-to-tagconstructs the relevant HTML elements from that specification. -
The runtime mounts the generated elements.
The renderer resolves the destination element and applies its mounting behavior.
json-renderers-build
prepares the structure, json-to-tag creates the elements, and json-renderers
coordinates and mounts the result.3. Main features
Creates a table with headers and rows from the supplied data. The README documents Bootstrap table classes.
Builds a select element and populates it with the provided options.
Can add option elements to an already-existing select element.
Supports default content replacement and a prepend option.
The README documents a browser bundle that registers under window.ks.jsonRenderers.
Can be used through the package or a browser ES module bundle.
Documented renderer types: table, select,
and selectOptionsOnly.
4. Installation
Option A β npm
Install the package in your JavaScript project:
npm install json-renderers
Then import the default render function in your JavaScript module:
import render from "json-renderers";
Option B β browser ES module bundle
The README documents loading the v13 bundle from jsDelivr:
<script type="module" src="https://cdn.jsdelivr.net/gh/keshavsoft/json-renderers@main/docs/dist/v13/min.js"></script>
According to the README, the browser bundle registers a global API at
window.ks.jsonRenderers,
including renderToDom.
5. Quick start examples
Each example needs a destination element in the HTML and a call to render with the
corresponding options. The snippets below follow the examples documented in the repository README.
Example A β render a table
<div id="table-container"></div>
import render from "json-renderers";
const records = [
{ id: 101, name: "Alpha Enterprise", city: "Hyderabad" },
{ id: 102, name: "Beta Logistics", city: "Bengaluru" }
];
render({
type: "table",
targetHtmlId: "table-container",
data: records,
columns: ["Name", "City"]
});
Expected result: a table is mounted inside the #table-container element,
showing
the selected columns and data rows.
Example B β render a select dropdown
<div id="dropdown-container"></div>
import render from "json-renderers";
render({
type: "select",
targetHtmlId: "dropdown-container",
data: ["Account Receivable", "Account Payable", "Sales Revenue"]
});
Expected result: a select element is generated with the supplied values as options.
Example C β add options to an existing select
<select id="user-role-select" class="form-select">
<option value="" disabled selected>Select Role...</option>
</select>
import render from "json-renderers";
render({
type: "selectOptionsOnly",
targetHtmlId: "user-role-select",
data: ["Administrator", "Editor", "Viewer"]
});
Expected result: options for Administrator, Editor, and Viewer are added to the existing select control.
6. API reference
The README documents the default export as a render function receiving one options object.
render({
type = "table",
targetHtmlId,
data,
columns,
appendPosition,
showLog = false
});
| Parameter | Type | Default | Purpose |
|---|---|---|---|
type |
String | "table" |
Selects the renderer: table, select, or
selectOptionsOnly.
|
targetHtmlId |
String | Not set | ID of the destination element resolved through document.getElementById(...). |
data |
Array | [] |
Row objects for a table; string values for select/dropdown option renderers. |
columns |
Array | Not set | Table column headers; the README describes strings or objects such as
{ title: "Name" }.
|
appendPosition |
String | Not set | Use "prepend" to prepend content. Otherwise, the documented behavior replaces
existing container content. |
showLog |
Boolean | false |
Enables debug logging during rendering. |
Return value
The README describes the return value as an HTMLElement representing the mounted DOM
container.
targetHtmlId
already
exists in the page before calling the render function. The parameter is an element ID, not a CSS selector.
7. How it differs from json-renderers-build
These packages work together, but they have different responsibilities.
json-renderers-build β
- Prepares the JSON component specification.
- Combines component blueprints with input data and options.
- Produces a declarative specification, rather than directly mounting DOM.
json-renderers
- Coordinates the full render path.
- Passes the spec to
json-to-tagfor element construction. - Mounts the resulting nodes into the target browser container.
| Aspect | json-renderers-build | json-renderers |
|---|---|---|
| Primary job | Build UI specification | Coordinate and mount rendered UI |
| Output / result | Declarative JSON spec | Rendered DOM mounted in a page |
| DOM mounting | Not its main responsibility | Core runtime responsibility |
| Typical use | Build custom or reusable specifications | Render components in browser applications |
8. Project structure
The README describes the repository as organized around source runtime code, browser documentation/build output, and runnable samples.
json-renderers/
βββ docs/ # Documentation and distribution
β βββ dist/ # Built browser bundles
β β βββ min.js
β β βββ v13/min.js
β βββ index.html # Docs and interactive workbench
βββ samples/ # Browser examples
β βββ table/
β βββ select/
β βββ selectOptionsOnly/
βββ src/ # Source code
β βββ index.js # Package entry
β βββ v13/ # Runtime implementation
β βββ buildSpec/
β βββ meta.js
β βββ registerGlobal.js
β βββ index.js
βββ package.json
βββ vite.config.js
βββ README.md
File paths and bundle names can change over time; use the repositoryβs current default branch as the source of truth.
9. Development and build
To run the project locally, the README documents the following commands:
# Install dependencies
npm install
# Start the Vite development server
npm run dev
# Build production bundles
npm run build
Use npm run dev to work with the project locally, then npm run build to build
the
production bundles described in the README. Consult package.json for the exact scripts in the
current checkout.
Practical troubleshooting
- Nothing renders: confirm the target container exists and that
targetHtmlIdmatches its ID exactly. - Wrong component appears: check the
typevalue and the shape ofdata. - Table columns are missing: verify the
columnsarray matches the intended record properties/headers. - Unexpectedly replaced content: review
appendPosition; the README describes replacement as the default andprependas an alternative.
10. Official links and references
This guide is based on the repositoryβs README and documentation links available when the page was prepared. Check these sources for the latest implementation details.
License The README identifies the project as MIT-licensed. See the repositoryβs current LICENSE file for the license text.
Explore More Documentation
Looking for a quick conceptual model or interactive live playground?