ProvenPin Install

json5 parse and stringify: working versions (tested 2026-10-16)

Parse JSON5 text that uses comments, trailing commas, unquoted keys and hex numbers; stringify with options; assert parsed values and a SyntaxError on invalid input. Offline.

passed3 passed · 0 failed2026-10-16 19:54 UTC
Status
passed
Last passed
2026-10-16 19:54 UTC
Tests
3 / 3
Language
TypeScript
Runtime
node v22.23.3
pinned versions3
json5@2.2.3@types/node@26.6.5tsx@4.23.15
run it
npm install --no-audit --no-fund --ignore-scripts=false
npm test
test environment
node v22.23.3
linux 6.17.0-1022-azure
x64
runner: github-actions 38958328921

The code

Exactly the files that passed. Your agent can pull them with get_recipe("json5-parse-stringify") (install), or see them on GitHub.

package.json
{
  "name": "json5-parse-stringify",
  "private": true,
  "type": "module",
  "scripts": {
    "test": "node --import tsx --test test/*.test.ts"
  },
  "dependencies": {
    "json5": "2.2.3"
  },
  "devDependencies": {
    "@types/node": "26.6.5",
    "tsx": "4.23.15"
  }
}
src/parse.ts
import JSON5 from "json5";

export type Config = {
  name: string;
  retries: number;
  tags: string[];
  nested: { enabled: boolean; mask: number };
};

export function parseConfig(text: string): Config {
  return JSON5.parse(text) as Config;
}

export function stringifyConfig(config: Config, space: number | string = 2): string {
  return JSON5.stringify(config, null, space);
}
test/parse.test.ts
import { test } from "node:test";
import assert from "node:assert/strict";
import { parseConfig, stringifyConfig, type Config } from "../src/parse.ts";

const source = `
// ProvenPin sample config
{
  name: 'provenpin',
  retries: 0x10, // hex integer
  tags: ['offline', 'json5',],
  nested: {
    enabled: true,
    mask: 0xff,
  },
}
`;

test("parses JSON5 with comments, trailing commas, unquoted keys and hex numbers", () => {
  const config = parseConfig(source);
  assert.equal(config.name, "provenpin");
  assert.equal(config.retries, 16);
  assert.deepEqual(config.tags, ["offline", "json5"]);
  assert.equal(config.nested.enabled, true);
  assert.equal(config.nested.mask, 255);
});

test("stringify with options round-trips through the parser", () => {
  const config: Config = {
    name: "provenpin",
    retries: 3,
    tags: ["a", "b"],
    nested: { enabled: true, mask: 255 },
  };
  const pretty = stringifyConfig(config, 2);
  assert.ok(pretty.includes("\n"));
  assert.match(pretty, /name:\s*'provenpin'/);
  assert.deepEqual(parseConfig(pretty), config);

  const compact = stringifyConfig(config, 0);
  assert.ok(!compact.includes("\n"));
  assert.deepEqual(parseConfig(compact), config);
});

test("throws a SyntaxError on invalid input", () => {
  assert.throws(() => parseConfig("{ name: 'unterminated }"), SyntaxError);
});

Connect to ProvenPin

Add the free MCP server so your agent can pull this recipe and others like it. Same setup as the docs.

terminal
claude mcp add --transport http provenpin https://mcp.provenpin.com/mcp

Any other MCP client: Streamable HTTP at https://mcp.provenpin.com/mcp. No API key, no signup.