Back to Explore

sindresorhus/parse-json

GitHub
1 watchersOpen source

Last release: 4/9/2025

parse-json is a JavaScript utility for parsing JSON while producing more helpful error messages than the built-in JSON.parse, including line and column details and a code frame. It throws a JSONError that supports instanceof checks and can include an optional filename to improve the displayed error context.

Project status

  • Actively maintained, with a recent upstream push on 2025-04-09 and version updates as late as v8.3.0 (2025-04-09).
  • Update cadence appears intermittent, with a long gap from v8.1.0 (2023-11-22) to v8.2.0 (2025-03-21), then a much shorter gap to v8.3.0 (2025-04-09).

AI summary generated Today

AI-generated from public sources. May be inaccurate. Report

Recent updates

  • v8.3.0

    4/9/2025

    Release v8.3.0 primarily updates dependencies. However, the code diff shows a behavioral change in error location calculation inside index.js, which is not mentioned in the release notes.

  • v8.2.0

    3/21/2025

    v8.2.0 improves JSON parse errors by attaching the original thrown SyntaxError from JSON.parse to JSONError.cause. The implementation also refactors JSONError to lazily generate its message and code frames, and updates documentation examples accordingly.

    Features
  • v8.1.0

    11/22/2023

    v8.1.0 primarily removes the runtime dependency on `json-parse-even-better-errors`. The diff shows that this is not a pure dependency cleanup, the library now generates and rewrites JSON parse error messages itself, which changes the resulting error strings and how location/code frames are derived.

  • v8.0.1

    11/9/2023

    v8.0.1 is a small patch release intended to improve the error code frame produced when parsing invalid JSON, specifically around parsing `{`. The diff also includes a refactor of JSONError message handling and an adjustment to how error locations are computed when the reported index is out of bounds.

  • v8.0.0

    11/2/2023

    v8.0.0 primarily raises the minimum supported Node.js version to 18. The release notes mention only that breaking requirement, but the actual code changes include a rewritten JSONError implementation and updated error-positioning logic plus dependency swaps.

    Breaking
  • v7.1.1

    10/27/2023

    v7.1.1 updates parse-json to fix the reported code frame formatting for Node.js v21 by adjusting how the parser extracts the error location from Node's JSON.parse error message. The change also updates CI to include Node 20 and 21 and refines the test expectations around Node-specific error message formats.

  • v7.1.0

    9/1/2023

    v7.1.0 adds a new `rawCodeFrame` string property to the `JSONError` thrown by `parse-json`. It also updates TypeScript types and tests to reflect the new property and includes documentation for it.

    Features
  • v7.0.0

    4/7/2023

    v7.0.0 raises the minimum Node.js requirement to Node 16 and introduces TypeScript typings (including a JSONError type). The release notes are minimal, but the actual diff also shows dependency major-version bumps and documentation changes around how JSONError is referenced.

    BreakingFeatures
  • v6.0.2

    11/21/2021

    v6.0.2 updates how parse-json depends on `lines-and-columns`. The release notes only mention fixing the dependency, and do not describe any behavioral impact from the underlying major dependency change.

  • v6.0.1

    11/15/2021

    v6.0.1 is a small compatibility-only release that targets Webpack issues. The documented change is specifically a Webpack compatibility fix, and the code diff shows it by altering how the `lines-and-columns` dependency is loaded.