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

rantjs

v2.1.0

Published

A procedural text generator for JavaScript

Downloads

610

Readme

Rantjs

Procedural text for JavaScript. Write a pattern, get a sentence.

Inspired by Rant. This is the Rantjs dialect (<noun>, [rep:3]{...}), not a Rant 4 VM.

import { rant } from "rantjs";

const sentence = rant(
  "<firstname male> likes to <verb-transitive> <noun.plural> with <pron poss male> pet <noun-animal> on <timenoun dayofweek plural>.",
);

console.log(sentence);
// 'Sean likes to chop parrots with his pet cat on Saturdays.'
npm install rantjs
npx rantjs --seed 42 '<firstname male> found [a] <noun-animal>.'

Patterns

Queries pull a random dictionary entry. Filters and inflections can be separated with a space, dash, or dot:

<firstname male>
<noun-animal plural>
<verb.ed>
<pron poss male>
<yn yes>

Blocks choose an alternative. A block with no repeater runs once. | splits options. Nested braces work.

{heads|tails}
{Example text}
[rep:3][sep:\s]{click|clack}

Tags

| Tag | Effect | | --- | --- | | [case:none\|default\|first\|word\|title\|upper\|lower\|sentence] | Casing for the finished string | | [rep:n] | Repeat the next block n times | | [sep:\s\|\n\|literal] | Join those repetitions | | [a] | Insert a or an before the next word | | [if:name]{then}{else} | Branch on whether carrier name is set |

Carriers remember a result so a character stays the same person:

<firstname male :: hero> saw <::hero> in the <place>.

Escapes: \C is a random A–Z letter.

NSFW entries are omitted unless the query asks (<noun nsfw>) or you pass { nsfw: true }.

API

import { rant, createRant, enUS } from "rantjs";

rant(pattern);
rant(pattern, { seed: 42 });
rant(pattern, { seed: "chapter-1", nsfw: false, dictionary: enUS });
rant(pattern, customDictionary); // 1.x-compatible second argument

const r = createRant({ seed: 42 });
r.run(pattern);
r.run(pattern, { seed: 99 });

Custom dictionary shape:

const pets = {
  tables: {
    pet: {
      name: "pet",
      subs: ["default", "plural"],
      entries: [{ forms: ["capybara", "capybaras"], classes: ["animal"] }],
    },
  },
};

Browser

ESM:

<script type="module">
  import { rant } from "https://cdn.jsdelivr.net/npm/[email protected]/+esm";
  document.body.textContent = rant("<greet> <firstname>.");
</script>

Script tag (cdnjs / jsDelivr):

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/rant.min.js"></script>
<script>
  document.body.textContent = rant("<greet> <firstname>.");
</script>

The IIFE build assigns rant on globalThis. The Node/ESM build does not touch window.

CLI

rantjs '<pattern>'
rantjs --seed 7 -f story.rant
rantjs --nsfw '<adj nsfw> <noun>'

Development

npm install
npm test
npm run demo          # playground at http://localhost:5173

Dictionary sources live in vocab/ (Rantionary plus a few custom tables). npm run build:dict compiles them into src/dictionaries/en-US.ts.

The playground is npm run demo. After GitHub Pages is enabled it will live at https://robbestad.github.io/Rantjs/.

Migrating from 1.x

  • Node 18+.
  • import { rant } from "rantjs" (or require("rantjs").rant).
  • window.rant is only set by the IIFE browser file, not by require("rantjs").
  • String.prototype is no longer patched.
  • Some dictionary words changed; the query syntax did not.

License

ISC