New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

jsonftw

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonftw

A minimal JSON-first web UI framework.

latest
npmnpm
Version
0.0.5
Version published
Maintainers
1
Created
Source

jsonftw

JSON for the Web — a tiny declarative frontend framework using pure JSON to describe your UI, events, and behavior.

What is jsonftw?

jsonftw is a minimal web framework that renders your application UI using only JSON definitions. It supports:

  • Declarative UI via JSON
  • CSS injection
  • Nested DOM structures
  • Inline JavaScript behavior (like onClick)
  • Page-level script execution
  • Hash-based client-side routing

It’s perfect for building visual editors, low-code platforms, documentation UIs, or any project where UI should be data-defined.

Installation

To use jsonftw in a project:


npm install jsonftw     # Install
npx jsonftw@latest      # Scaffold new project using JSONFTW

Usage

1. Create a container in your HTML

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>jsonftw App</title>
  </head>
  <body>
    <div id="app"></div>
    <script type="module" src="./main.js"></script>
  </body>
</html>

2. Import and start the framework

// main.js
import { startJsonFTW } from "jsonftw";
startJsonFTW();

3. Add a routes/home.json file

{
  "cssFile": "styles.css",
  "renderOn": "app",
  "view": [
    {
      "type": "div",
      "identifier": "container",
      "class": "wrapper"
    },
    {
      "type": "h1",
      "identifier": "main-title",
      "innerText": "Welcome to jsonftw",
      "insideOf": {
        "childElement": true,
        "parentElement": "container"
      }
    },
    {
      "type": "button",
      "identifier": "click-button",
      "innerText": "Click Me",
      "onClick": "alert('Hello from jsonftw!');",
      "insideOf": {
        "childElement": true,
        "parentElement": "container"
      }
    }
  ],
  "javascript": "console.log('Page loaded');"
}
<a href="#/">Home</a> <a href="#/about">About</a>

JSON Schema Reference

Each route is a .json file with the following structure:

FieldTypeRequiredDescription
cssFilestringoptionalPath to an external stylesheet to load
renderOnstringoptionalDOM id to render into (default: app)
viewarrayA list of DOM element definitions
javascriptstringoptionalPage-level inline JavaScript to run after render

Element Definition (view[])

FieldTypeRequiredDescription
typestringHTML element tag (e.g., div, h1, input)
identifierstringUnique key used internally for nesting
classstringoptionalclass attribute
idstringoptionalid attribute
stylestringoptionalInline style (e.g., "color: red;")
innerTextstringoptionalText content
valuestringoptionalFor input elements
srcstringoptionalFor img, video, iframe, etc.
hrefstringoptionalFor a tags
placeholderstringoptionalFor inputs
onClickstringoptionalInline JS for click handler
insideOfobjectoptionalNest inside a parent element ({ childElement: true, parentElement: "id" })

Example Output

Given the JSON:

{
  "view": [
    {
      "type": "div",
      "identifier": "wrapper"
    },
    {
      "type": "h1",
      "innerText": "Hello World",
      "identifier": "title",
      "insideOf": { "childElement": true, "parentElement": "wrapper" }
    }
  ]
}

Output DOM:

<div data-identifier="wrapper">
  <h1 data-identifier="title">Hello World</h1>
</div>

Advanced Features

✅ CSS injection

Set a cssFile in your route JSON and it will be <link>-injected into <head> if not already loaded.

✅ Routing

Uses window.location.hash to route to routes/<page>.json.

Examples:

  • #/routes/home.json
  • #/aboutroutes/about.json

✅ JavaScript execution

You can include a string of JS in:

  • onClick
  • javascript (top-level)

It will be evaluated using new Function(...).

File Structure Example

my-app/
├── index.html
├── main.js
├── routes/
│   └── home.json
├── styles.css
├── node_modules/
└── package.json

License

MIT — free to use and modify.

Feedback / Contributions

Feel free to open issues or PRs! jsonftw is built to be hackable and extendable.

Keywords

json

FAQs

Package last updated on 18 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts