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 🙏

© 2026 – Pkg Stats / Ryan Hefner

objgen

v4.0.4

Published

ObjGen Node.js package

Readme

objgen-js

ObjGen.js is a code and data generation package that allows users to express and generate complex content using a simple model based templating syntax.

The ObjGen.js Node package is the code that enables the Live JSON Generator available at objgen.com - To see the generator in action, check out the live demo.

JSON Generator

  • JSON properties are defined by entering names
  • Data types are specified using a simple convention:
    • s (or string) = string, textual data
    • n (or number) = numbeical data
    • d (or date) = date/time
    • b (or bool) = booleans
    • [] = to define an array
  • Data types can be abbreviated since the first character is significant: str, num, bool, etc.
  • Complex types and data are created by nesting (or tabbing) new properties in a new level. For example:
id n
name s
phones
  work s
  cell s

will generate:

{
  "id": 0,
  "name": "",
  "phones": {
    "work": "",
    "cell": ""
  }
}

Assignments are defined by using the equal sign '='. For example:

id n = 0
name = Dave Kingman

will generate:

{
  "id": 0,
  "name": "Dave Kingman"
}

Any assignment for a property that does not include a data type, defaults to a string.

Dates values default to the current date, but can be assigned using a variety of parseable date values. For example:

id n = 0
name = Dave Kingman
dateOfBirth d = 2112/12/21

will generate:

{
  "id": 0,
  "name": "Dave Kingman",
  "dateOfBirth": "2112-12-21T05:00:00.000Z"
}

Arrays are defined by using brackets '[]', with indices optional. For example:

id n = 12123434
name = Joe Rightsman
address[]
  street=100 East Main Street
  city=Southernville
  state=NY
  zip=19910
address[]
  street=100 West Birch Lane
  city=Northnville
  state=NY
  zip=19911

will generate:

{
  "id": 12123434,
  "name": "Joe Rightsman",
  "address": [
    {
      "street": "100 East Main Street",
      "city": "Southernville",
      "state": "NY",
      "zip": "19910"
    },
    {
      "street": "100 West Birch Lane",
      "city": "Northnville",
      "state": "NY",
      "zip": "19911"
    }
  ]
}

A JSON array object can be generated using the following syntax:

[]
  id n = 1
  name = value 1
[]
  id n = 2
  name = value 2
[]
  id n = 3
  name = value 3

will generate:

[
  {
    "id": 1,
    "name": "value 1"
  },
  {
    "id": 2,
    "name": "value 2"
  },
  {
    "id": 3,
    "name": "value 3"
  }
]

Installation

  1. Get node
  2. npm install objgen --save or globally with npm install -g objgen for command line usage
  3. Verify -g installation
$ objgen --version
4.0

Usage

JavaScript - Calling the JSON Generator

var ObjGen = require('./objgen.js').ObjGen;

var model = "id n = 100\n" +
  "title = Welcome to New York\n" +
  "releaseDate d = 2017-02-10";

var json = ObjGen.xJson(model, {numSpaces: 2});

console.log(json);

generates:

{
  "id": 100,
  "title": "Welcome to New York",
  "releaseDate": "2017-02-10T00:00:00.000Z"
}

Command line - Run the JSON generation demo

$ objgen -d

Input model:

// Model & generate Live JSON data values
// interactively using a simple syntax.
// String is the default value type
product = ObjGen Live JSON generator

// Number, Date & Boolean are also supported
// Specify types after property names
version n = 4.0
releaseDate d = 2017-02-10
demo b = true

// Tabs or spaces define complex values
person
  id number = 12345
  name = John Doe
  phones
    home = 800-123-4567
    mobile = 877-123-1234

  // Use [] to define simple type arrays
  email[] s = [email protected], [email protected]
  dateOfBirth d = 1990-01-02
  registered b = true

  // Use [n] to define object arrays
  emergencyContacts[0]
    name s = Jane Doe
    phone s = 888-555-1212
    relationship = spouse
  emergencyContacts[1]
    name s = Justin Doe
    phone s = 877-123-1212
    relationship = parent

// See http://objgen.com for additional info
// We hope you enjoy the tool!


Generated JSON:

{
  "product": "ObjGen Live JSON generator",
  "version": 4,
  "releaseDate": "2017-02-10T00:00:00.000Z",
  "demo": true,
  "person": {
    "id": 12345,
    "name": "John Doe",
    "phones": {
      "home": "800-123-4567",
      "mobile": "877-123-1234"
    },
    "email": [
      "[email protected]",
      "[email protected]"
    ],
    "dateOfBirth": "1990-01-02T00:00:00.000Z",
    "registered": true,
    "emergencyContacts": [
      {
        "name": "Jane Doe",
        "phone": "888-555-1212",
        "relationship": "spouse"
      },
      {
        "name": "Justin Doe",
        "phone": "877-123-1212",
        "relationship": "parent"
      }
    ]
  }
}

Command line - Generate JSON from your own model files:

$ objgen -f my-model.txt