JavaScript JSON libraries

Updated Nov 2026

JavaScript JSON libraries parse and serialize JSON beyond what the built-in JSON.parse and JSON.stringify handle. Each one extends that pair in one direction, such as comments in configuration files, sorted keys for stable hashes, or circular references. These libraries read the configuration files, cache keys, and logged objects that apps and developer tools exchange as JSON.

Popularity

JSON5 has the most monthly downloads in this comparison, at 1.2B.

LibraryMonthly downloadsStarsLast releaseLicense
JSON5
1.2B
7.2KDec 2022MIT
fast-json-stable-stringify
811.8M
Not on GitHubDec 2019MIT
flatted
797.9M
1.2KJul 2026ISC
parse-json
727.1M
Not on GitHubApr 2025MIT
json-stable-stringify-without-jsonify
700.0M
Not on GitHubDec 2016MIT
@ungap/structured-clone
493.6M
Not on GitHubAug 2026ISC
jsonc-parser
414.0M
Not on GitHubJun 2024MIT
safe-stable-stringify
363.2M
Not on GitHubNov 2026MIT
Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Features compared

LibraryParses commented inputDeterministic key sortingPreserves cyclic references
JSON5Built-inUnsupportedUnsupported
fast-json-stable-stringifyUnsupportedBuilt-inUnsupported
flattedUnsupportedUnsupportedBuilt-in
parse-jsonUnsupportedUnsupportedUnsupported
json-stable-stringify-without-jsonifyUnsupportedBuilt-inUnsupported
@ungap/structured-cloneUnsupportedUnsupportedBuilt-in
jsonc-parserBuilt-inUnsupportedUnsupported
safe-stable-stringifyUnsupportedBuilt-inUnsupported
Built-inNot supported

Libraries and code examples

Parses and serializes configuration text with syntax beyond standard JSON.

Downloads / mo
1.2B
Stars
7.2K
Last release
2.2.3
License
MIT

Strengths

  • Accepts configuration comments. Keep single-line or multi-line comments in configuration files.
  • Reads standard JSON too. Parse existing valid JSON files without converting their syntax.

Limitations

  • Targets human-edited configuration. Use JSON for machine-to-machine communication.

Quickstart

From README.md
$ npm install json5@2.2.3
const JSON5 = require('json5');

const config = JSON5.parse('{ enabled: true, }');

JSON5 examples

From open-source projects on GitHub
export function parseConfigOverrides(configOverrides: string): any {
  const trimmed = configOverrides.trim();
  if (!trimmed) {
    return {};
  }
  return JSON5.parse(trimmed);
}

fast-json-stable-stringify

Stringifies objects with their keys in sorted order for a deterministic result.

Downloads / mo
811.8M
Last release
2.1.0
License
MIT

Strengths

  • Custom key comparison. A comparison function sets the order of object keys in the output.

Quickstart

From README.md
$ npm install fast-json-stable-stringify@2.1.0
const stringify = require('fast-json-stable-stringify');

const text = stringify({ b: 2, a: 1 });

fast-json-stable-stringify examples

From open-source projects on GitHub

Serializes and restores circular object structures using a paired wire format.

Downloads / mo
797.9M
Stars
1.2K
Last release
3.4.4
License
ISC

Strengths

  • Restores circular object links. Pair stringify and parse to round-trip recursive structures.
  • Filters values during serialization. Pass a replacer to control which values stringify emits.

Limitations

  • Requires its matching parser. Pair flatted output with flatted.parse to restore references correctly.
  • Supports JSON-compatible values only. Objects such as sockets do not round-trip as their original classes.

Quickstart

From README.md
$ npm install flatted@3.4.4
const { stringify } = require('flatted');

const value = {};
value.self = value;
const text = stringify(value);

flatted examples

From open-source projects on GitHub

Parses JSON and throws errors that show the failing line in a code frame.

Downloads / mo
727.1M
Last release
8.3.0
License
MIT

Strengths

  • Names the source file. An optional filename appears in the error message.

Limitations

  • Throws on invalid JSON. A parsing error throws a JSONError rather than returning a partial value.

Quickstart

From readme.md
$ npm install parse-json@8.3.0
import parseJson from 'parse-json';

const value = parseJson('{"enabled":true}');

parse-json examples

From open-source projects on GitHub
export function parse(jsonString, file = '') {
    try {
        return parseJson(jsonString);
    } catch (e) {
        throw new Error(`${file} - ${e.message}`);
    }
}

json-stable-stringify-without-jsonify

Stringifies objects deterministically without the unlicensed jsonify dependency.

Downloads / mo
700.0M
Last release
1.0.1
License
MIT

Strengths

  • Consistent hashes. Equal objects produce the same string and the same hash.

Quickstart

From readme.markdown
$ npm install json-stable-stringify-without-jsonify@1.0.1
const stringify = require('json-stable-stringify-without-jsonify');

const text = stringify({ b: 2, a: 1 });

json-stable-stringify-without-jsonify examples

From open-source projects on GitHub

@ungap/structured-clone

Clones and serializes values with types beyond JSON, including recursive data, as a structuredClone polyfill.

Downloads / mo
493.6M
Last release
1.4.0
License
ISC

Strengths

  • Serialized output is JSON-safe. Recursive values pass through JSON.stringify and deserialize intact.

Limitations

  • No Blob or File support. Blob, File, ImageBitmap, and other non-JavaScript types are not supported yet.

Quickstart

From README.md
$ npm install @ungap/structured-clone@1.4.0
import { stringify } from '@ungap/structured-clone/json';

const text = stringify({ any: 'serializable' });

@ungap/structured-clone examples

From open-source projects on GitHub

Scans, parses, and edits JSON with JavaScript-style comments.

Downloads / mo
414.0M
Last release
3.3.1
License
MIT

Strengths

  • Computes document edits. The modify API returns edits that insert, remove, or replace a value in a document.

Limitations

  • Parses past errors. The error list, rather than an exception, reports invalid input.

Quickstart

From README.md
$ npm install jsonc-parser@3.3.1
const { parse } = require('jsonc-parser');

const errors = [];
const value = parse('{ /* configuration */ "enabled": true }', errors);
if (errors.length) throw new Error('Invalid JSONC');

jsonc-parser examples

From open-source projects on GitHub

safe-stable-stringify

Stringifies values deterministically and handles circular structures and BigInt instead of throwing.

Downloads / mo
363.2M
Last release
3.0.1
License
MIT

Strengths

  • No dependencies. The package installs with no dependencies in ESM or CommonJS projects.

Limitations

  • Circular references become placeholders. Each circular reference becomes the configured placeholder value in the output.

Quickstart

From readme.md
$ npm install safe-stable-stringify@3.0.1
const stringify = require('safe-stable-stringify');

const text = stringify({ b: 2, a: 1 });

safe-stable-stringify examples

From open-source projects on GitHub

FAQ

structuredClone is the HTML standard's function for deep copies of values, including types that JSON cannot hold. @ungap/structured-clone supplies it as a polyfill and also exports a serializer whose output can be stringified as JSON.

JSON5 is a superset of JSON for configuration files that people write by hand. Valid JSON files are also valid JSON5 files.

JSONC is JSON with JavaScript-style comments. jsonc-parser scans, parses, and edits JSONC documents and also reads standard JSON.

Standard JSON has no comments. JSON5 and jsonc-parser both parse files that contain them.

JSONC adds JavaScript-style comments to JSON. JSON5 accepts comments as well as other syntax that people use in hand-written configuration.

flatted writes circular references in its own format and restores them with flatted.parse. safe-stable-stringify replaces each circular reference with a placeholder value rather than throwing.

For coding agents

Found your JSON library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official