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

parse-part-json

v1.1.0

Published

Can parse an incomplete JSON string

Readme

parse-part-json

This is a library that can parse incomplete JSON

Installation

$ npm i parse-part-json

Demo

ESModule:

import { parsePartJson } from 'parse-part-json'

Commonjs:

const { parsePartJson } = require('parse-part-json')

Example:

/**
 * note: This is not a complete JSON
 */
const json1 = `{"name": "John", "age": 30`

const result1 = parsePartJson(json1)
console.log(result1) // { name: 'John', age: 30 }

/**
 * Default tolerance for incomplete parsing of basic types
 */
const json2 = `{"name": "John", "age":nu`
const result2 = parsePartJson(json2)
console.log(result2) // { name: 'John', age: null }

// this throw BasicParseIncomplete Error
const result3 = parsePartJson(json2, { tolerateBasicIncomplete: false })

Preview

https://parse-part-json-demo.vercel.app/

Speed compare

The functionality of the partial-json library is the same as that of the parse-part-json library. Based on my terminal testing and comparison, their JSON parsing speeds vary depending on the data type, but in most cases, parse-part-json is 20–30% faster than partial-json.

import { parse } from 'partial-json'
import { parsePartJson } from 'parse-part-json'

const json1 = `{
  "appName": "WeatherTracker",
  "version": "1.2.0",
  "features": ["forecast", "alerts", "maps"],
  "settings": {
    "units": "metric",
    "language": "en",
    "notifications": true
  },
  "sampleData": {
    "cities": [
      {
        "id": 1001,
        "name": "Springfield",
        "temperature": 22.5,
        "conditions": "partly cloudy"
      },
      {
        "id": 1002,
        "name": "Shelbyville",
        "temperature": 19.8,
        "conditions": "sunny"
      }
    ],
    "updateTimestamp": "2023-05-16T14:30:00Z"
  },
  "metadata": {
    "developer": "Acme Apps",
    "releaseYear": 2023,
    "supportedOS": ["Android", "iOS", "`

// tset result:true
console.log(
  JSON.stringify(parse(json1)) === JSON.stringify(parsePartJson(json1))
)

//test speed
let start = Date.now()
for (let i = 0; i < 100000; i++) {
  parse(json1)
}
let end = Date.now()
// parse: 6023ms
console.log(`parse: ${end - start}ms`)

let start2 = Date.now()
for (let i = 0; i < 100000; i++) {
  parsePartJson(json1)
}
let end2 = Date.now()
// parsePartJson: 1259ms
console.log(`parsePartJson: ${end2 - start2}ms`)
The time consumed for parsing 100000 times in the same JSON segment (note: the results may vary depending on the device):

parse-part-json : 1259ms

partial-json : 6023ms

Support

ESModule、Commonjs