npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

jsonftw

v0.0.5

Published

A minimal JSON-first web UI framework.

Downloads

19

Readme

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');"
}

4. Enable routing with hash links

<a href="#/">Home</a> <a href="#/about">About</a>

JSON Schema Reference

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

| Field | Type | Required | Description | | ------------ | -------- | -------- | ------------------------------------------------ | | cssFile | string | optional | Path to an external stylesheet to load | | renderOn | string | optional | DOM id to render into (default: app) | | view | array | ✅ | A list of DOM element definitions | | javascript | string | optional | Page-level inline JavaScript to run after render |


Element Definition (view[])

| Field | Type | Required | Description | | ------------- | -------- | -------- | ---------------------------------------------------------------------------- | | type | string | ✅ | HTML element tag (e.g., div, h1, input) | | identifier | string | ✅ | Unique key used internally for nesting | | class | string | optional | class attribute | | id | string | optional | id attribute | | style | string | optional | Inline style (e.g., "color: red;") | | innerText | string | optional | Text content | | value | string | optional | For input elements | | src | string | optional | For img, video, iframe, etc. | | href | string | optional | For a tags | | placeholder | string | optional | For inputs | | onClick | string | optional | Inline JS for click handler | | insideOf | object | optional | Nest 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.