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

jsonmend

v0.1.3

Published

Mends the JSON your LLM almost wrote — repair + true incremental streaming, defined by an open conformance corpus

Readme

jsonmend (JavaScript)

Mends the JSON your LLM almost wrote.

JavaScript port of jsonmend — same engine design, same repair semantics, verified against the same conformance corpus (485/485). The Python and JS implementations repair identically, so a model output parses the same on both sides of your stack.

Zero dependencies. Node ≥ 14, browsers, workers.

npm install jsonmend

Usage

import { repairJson, loads, Mender } from "jsonmend";

repairJson("{'name': 'John', age: 31");
// '{"name": "John", "age": 31}'

loads('```json\n{"ok": true,}\n```');
// { ok: true }

Streaming (true incremental)

const m = new Mender();
for await (const chunk of llmStream) {
  const partial = m.feed(chunk);   // best-effort value, O(new bytes)
  render(partial);                  // e.g. { answer: "The capital of Fr" }
}
const value = m.close();

Each feed() parses only the new bytes — re-parsing the whole buffer per chunk (what you have to do with a batch repairer) is O(n²) in total and hundreds of times slower on long outputs.

Note: V8 re-flattens the growing buffer string on access, so feeding a very large output one character at a time is super-linear on the JS side. Feed in reasonable chunks (whole SSE/tool-call deltas, or ≥256 B) and it stays fast. A prefix-discarding buffer that makes any feed size O(new bytes) is planned. (The Python package is already amortised O(1) per character.)

API

  • repairJson(text, options?) → repaired JSON string. Options: { returnObjects, skipJsonParse, strict }.
  • loads(text, options?) → parsed value (uses a JSON.parse fast path for valid input).
  • mend(text, options?) → parsed value, always through the repair machine.
  • new Mender()feed(chunk), value, close().

Integers beyond Number.MAX_SAFE_INTEGER are preserved as BigInt and serialized with exact digits. Output is always valid RFC 8259 JSON (NaN/Infinity serialize as null) and always UTF-8 encodable (lone surrogates are replaced).

What it fixes

Truncated objects/arrays/strings/numbers/literals · markdown fences · single/smart quotes · unescaped inner quotes · bare keys/values · Python literals · comments · trailing/missing commas · mismatched brackets · NDJSON · string concatenation · JSONP/MongoDB wrappers · tuples · ellipsis · BOM · broken escapes · 100k-deep nesting (no recursion).

See the main README for the full story, benchmarks and the conformance corpus.

License

MIT. The conformance corpus is CC0.