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

@vantezzen/streamable-json

v1.0.0

Published

> A small (<6kB, <2kB gzipped) JSON parser for streamed/possibly incomplete JSON data.

Readme

@vantezzen/streamable-json

A small (<6kB, <2kB gzipped) JSON parser for streamed/possibly incomplete JSON data.

@vantezzen/streamable-json is a TypeScript library that provides a JSON parser capable of handling streamed or incomplete JSON data. This is particularly useful if you get JSON from an LLM or slow, chunked sources where you can still handle partial data.

Demo: https://vantezzen.github.io/streamable-json/

Installation

You can install the package:

npm i @vantezzen/streamable-json
yarn add @vantezzen/streamable-json
pnpm add @vantezzen/streamable-json
bun add @vantezzen/streamable-json

Usage

Simply provide parse(yourJsonString) and it will return the parsed JSON object, even if the JSON string is incomplete.

import parse, { type DeepPartial } from "@vantezzen/streamable-json";

const data = parse(myJsonString) as DeepPartial<MyType>;

API

parse(jsonString, config?)

The main function for parsing JSON strings. Handles incomplete/partial JSON gracefully.

import parse from "@vantezzen/streamable-json";

const result = parse('{"name": "John", "age": 30}');
// { name: "John", age: 30 }

// Partial JSON also works
const partial = parse('{"name": "John", "ag');
// { name: "John" }

Parameters:

| Parameter | Type | Description | | ------------ | ----------------------- | -------------------------------------------- | | jsonString | string | The JSON string to parse (can be incomplete) | | config | Partial<ParserConfig> | Optional configuration options |

Returns: unknown - The parsed JSON value, or undefined if parsing fails

ParserConfig

Configuration options for the parser:

type ParserConfig = {
  allowPartialStrings?: boolean;
  allowPartialNumbers?: boolean;
};

| Option | Type | Default | Description | | --------------------- | --------- | ------- | -------------------------------------------------------------------------- | | allowPartialStrings | boolean | false | Include strings that are not yet closed (missing ending ") | | allowPartialNumbers | boolean | false | Include numbers that may be incomplete (e.g., 123 when expecting 1234) |

Example with options:

import parse from "@vantezzen/streamable-json";

// Without allowPartialStrings (default)
parse('{"name": "Joh');
// { } - incomplete string is excluded

// With allowPartialStrings
parse('{"name": "Joh', { allowPartialStrings: true });
// { name: "Joh" } - incomplete string is included

Parser class

For more control, you can use the Parser class directly:

import { Parser } from "@vantezzen/streamable-json";

const parser = new Parser('{"key": "value"}', {
  allowPartialStrings: true,
});
const result = parser.parse();

Constructor:

new Parser(sourceContent: string, config?: ParserConfig)

Methods:

| Method | Returns | Description | | --------- | --------- | ---------------------------------------------------------------------------- | | parse() | Element | Parses the JSON and returns the result. Results are cached after first call. |

Types

Element

The type representing any valid JSON element:

type Element =
  | string
  | number
  | boolean
  | null
  | object
  | Element[]
  | undefined;

DeepPartial<T>

A utility type that makes all properties of an object (and nested objects) optional. Useful for typing parsed results from incomplete JSON:

import parse, { type DeepPartial } from "@vantezzen/streamable-json";

interface User {
  name: string;
  profile: {
    age: number;
    email: string;
  };
}

const data = parse(incompleteJson) as DeepPartial<User>;
// data.name might be undefined
// data.profile?.age might be undefined

Development

To install dependencies:

bun install && cd example && bun install

To run:

bun test # run the JSON test suite
bun start # Run the stream demo - this will parse example.json in 10% increments

bun run dev # in the example directory

To build:

bun run build