{"_id":"@toolsycc/json-repair","_rev":"5-abbd17ca1911322545f319055b368d48","name":"@toolsycc/json-repair","dist-tags":{"latest":"0.1.22"},"versions":{"0.1.0":{"name":"@toolsycc/json-repair","version":"0.1.0","keywords":["json","repair","fix","parser","toolsy"],"author":{"name":"Sebastien Carriot","email":"sebastien@digiteld.com"},"license":"MIT","_id":"@toolsycc/json-repair@0.1.0","maintainers":[{"name":"sebog33","email":"sebastien@digiteld.com"}],"dist":{"shasum":"e784334349aa579e1c5bf1ed1ff53ce3df929be2","tarball":"https://registry.npmjs.org/@toolsycc/json-repair/-/json-repair-0.1.0.tgz","fileCount":4,"integrity":"sha512-QRlH0SvhvehHZG41aQ9kMd1pWfFqpzFKwLr2t+fT3PSrY8N5p/cgUbC6gdpJ3lKyCXZtkdL7KVQdDJ+cleBn7Q==","signatures":[{"sig":"MEYCIQDJNuwaZ7iTaqaPJA0IcSRhpAhOV+3IsEPs85vymh+zRAIhAOo+NY7ZZ1QTw/OyDqZnIoBZI3xru7ckOeN+pOmAkbEt","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":14869},"main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"import":"./dist/index.js","require":"./dist/index.js"}},"gitHead":"80e3839e6a43063984241faa7ac61e54eed62940","scripts":{"dev":"vitest watch","test":"vitest","build":"tsc"},"_npmUser":{"name":"sebog33","email":"sebastien@digiteld.com"},"_npmVersion":"10.9.1","description":"A robust utility to fix and repair broken JSON strings, especially from LLM output.","directories":{},"_nodeVersion":"20.18.0","_hasShrinkwrap":false,"devDependencies":{"vitest":"^3.1.1","typescript":"^5.0.0","@types/node":"^18.0.0"},"_npmOperationalInternal":{"tmp":"tmp/json-repair_0.1.0_1743630474175_0.5765981722830413","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@toolsycc/json-repair","version":"0.1.1","keywords":["json","repair","fix","parser","toolsy"],"author":{"name":"Sebastien Carriot","email":"sebastien@digiteld.com"},"license":"MIT","_id":"@toolsycc/json-repair@0.1.1","maintainers":[{"name":"sebog33","email":"sebastien@digiteld.com"}],"dist":{"shasum":"19467d43cb8fba60e2dedadee1084315aa6bb9fd","tarball":"https://registry.npmjs.org/@toolsycc/json-repair/-/json-repair-0.1.1.tgz","fileCount":4,"integrity":"sha512-i0TZuA08DsYgdfrqScUly59YP61S9qexw75GAPkVNbvHx7ZO34BcAEOcSn8p7NX4NEjGZptX6Ylsb3ZGFSPfDA==","signatures":[{"sig":"MEQCIHumORrSLh9bt5UPhUODE0KibMvpP8mG7m0UT1Vz4YpvAiBS/dng8drTonbAxkNXfoJe24X/MWaQMG2cuGlgTTWZbQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":15273},"main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"import":"./dist/index.js","require":"./dist/index.js"}},"gitHead":"80e3839e6a43063984241faa7ac61e54eed62940","scripts":{"dev":"vitest watch","test":"vitest","build":"tsc"},"_npmUser":{"name":"sebog33","email":"sebastien@digiteld.com"},"_npmVersion":"10.9.1","description":"A robust utility to fix and repair broken JSON strings, especially from LLM output.","directories":{},"_nodeVersion":"20.18.0","_hasShrinkwrap":false,"devDependencies":{"vitest":"^3.1.1","typescript":"^5.0.0","@types/node":"^18.0.0"},"_npmOperationalInternal":{"tmp":"tmp/json-repair_0.1.1_1743654571451_0.9679254957480337","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@toolsycc/json-repair","version":"0.1.2","keywords":["toolsy","json","repair","fix","parser","malformed","invalid","broken","llm"],"author":{"name":"Sebastien Carriot","email":"sebastien@digiteld.com"},"license":"MIT","_id":"@toolsycc/json-repair@0.1.2","maintainers":[{"name":"sebog33","email":"sebastien@digiteld.com"}],"dist":{"shasum":"d5127c76c8f50ca2c3570fa0d58334dbbf77fd3f","tarball":"https://registry.npmjs.org/@toolsycc/json-repair/-/json-repair-0.1.2.tgz","fileCount":4,"integrity":"sha512-3tYm7t8l+WFPfQ6qdsOaL05GQ1rg1X3OhJZo2gWydoltJSTqJcOzy807EjitcXuxNM6KC2ESe3QMW0e8c0WAtQ==","signatures":[{"sig":"MEQCIHUjaZvnPkaj4m8sRxCjYmWDEcThXbR2CoLtR5lvU2aaAiA2zcR/q0q4fuVUprqrSS9+FwVQRxv/VnNmuWLYAKQAeQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":15402},"main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"import":"./dist/index.js","require":"./dist/index.js"}},"gitHead":"bb7213c747c83e7485bed6ed0eca4a70f2030ed5","scripts":{"dev":"vitest watch","test":"vitest","build":"tsc"},"_npmUser":{"name":"sebog33","email":"sebastien@digiteld.com"},"_npmVersion":"10.9.1","description":"A robust utility to fix and repair broken JSON strings, especially from LLM output.","directories":{},"_nodeVersion":"20.18.0","_hasShrinkwrap":false,"devDependencies":{"vitest":"^3.1.1","typescript":"^5.0.0","@types/node":"^18.0.0"},"_npmOperationalInternal":{"tmp":"tmp/json-repair_0.1.2_1743659502657_0.035058020273978974","host":"s3://npm-registry-packages-npm-production"}},"0.1.21":{"name":"@toolsycc/json-repair","version":"0.1.21","keywords":["toolsy","json","repair","fix","parser","malformed","invalid","broken","llm"],"author":{"name":"Sebastien Carriot","email":"sebastien@digiteld.com"},"license":"MIT","_id":"@toolsycc/json-repair@0.1.21","maintainers":[{"name":"sebog33","email":"sebastien@digiteld.com"}],"dist":{"shasum":"b3543051dfbf4835c1fcacd555d570acff80fe26","tarball":"https://registry.npmjs.org/@toolsycc/json-repair/-/json-repair-0.1.21.tgz","fileCount":4,"integrity":"sha512-VAumI5cHpE0FUncvUn4orupEAoNkMATKlJG+PHSB2ucEkaSXkou3w1W23fAoB/9NpAa4BmN2Cgmuo4wI+EafEA==","signatures":[{"sig":"MEYCIQD9g/9XdK6b7r3K/APSoF3USI2/kccIlfaskrLQ1/HbjwIhAPPtosMX+yPErwhn8ikmx1TrGwfDF9sC7zrim5nlftBw","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":16804},"main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"import":"./dist/index.js","require":"./dist/index.js"}},"gitHead":"bb7213c747c83e7485bed6ed0eca4a70f2030ed5","scripts":{"dev":"vitest watch","test":"vitest","build":"tsc"},"_npmUser":{"name":"sebog33","email":"sebastien@digiteld.com"},"_npmVersion":"10.9.1","description":"A robust utility to fix and repair broken JSON strings, especially from LLM output.","directories":{},"_nodeVersion":"20.18.0","_hasShrinkwrap":false,"devDependencies":{"vitest":"^3.1.1","typescript":"^5.0.0","@types/node":"^18.0.0"},"_npmOperationalInternal":{"tmp":"tmp/json-repair_0.1.21_1743668928903_0.04015290037632968","host":"s3://npm-registry-packages-npm-production"}},"0.1.22":{"name":"@toolsycc/json-repair","version":"0.1.22","description":"A robust utility to repair JSON strings - fix malformed or broken JSON, especially from LLM output like ChatGPT.","main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"require":"./dist/index.js","import":"./dist/index.js"}},"scripts":{"build":"tsc","test":"vitest","dev":"vitest watch","release":"npm publish --access public","release:dry-run":"npm publish --access public --dry-run"},"keywords":["toolsy","json","repair","json repair","repair json","fix json","json fixer","fix broken json","fix malformed json","llm json","validate","check","fix","parser","malformed","invalid","broken","llm","ia","ai","chatgpt","gpt","openai","anthropic","claude","llama","deepseek","mistral","gemini","groq","qwen","grok","xai","o1","o3"],"author":{"name":"Sebastien Carriot","email":"sebastien@digiteld.com"},"license":"MIT","devDependencies":{"vitest":"^3.1.1","typescript":"^5.0.0","@types/node":"^18.0.0"},"_id":"@toolsycc/json-repair@0.1.22","gitHead":"f6b871b94a716668707c4aefaaa485e7e4919c1a","_nodeVersion":"20.18.0","_npmVersion":"10.9.1","dist":{"integrity":"sha512-IMrsxovS9a5pWGRxMCDQDW8FKKEZI/yK/HMcyJlbnd/s+Mk0dRtGr1BFicL276gDsPvb/JfNHtHSi1oc0eY1jA==","shasum":"7ad0eb30c4ef1c4286ad3487dc1bbda562f09986","tarball":"https://registry.npmjs.org/@toolsycc/json-repair/-/json-repair-0.1.22.tgz","fileCount":4,"unpackedSize":17591,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIEjyvhH7uFW08DWXWe7biSgsP+ofR/UKg9U7s0fAbY9IAiEA2chDphfrC19eEqE6VgOQAwkfHYOhPtjFRBWDPK316Ds="}]},"_npmUser":{"name":"sebog33","email":"sebastien@digiteld.com"},"directories":{},"maintainers":[{"name":"sebog33","email":"sebastien@digiteld.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/json-repair_0.1.22_1743713791680_0.48344190630335304"},"_hasShrinkwrap":false}},"time":{"created":"2025-04-02T21:47:54.119Z","modified":"2025-04-03T20:56:32.087Z","0.1.0":"2025-04-02T21:47:54.344Z","0.1.1":"2025-04-03T04:29:31.691Z","0.1.2":"2025-04-03T05:51:42.866Z","0.1.21":"2025-04-03T08:28:49.073Z","0.1.22":"2025-04-03T20:56:31.888Z"},"author":{"name":"Sebastien Carriot","email":"sebastien@digiteld.com"},"license":"MIT","keywords":["toolsy","json","repair","json repair","repair json","fix json","json fixer","fix broken json","fix malformed json","llm json","validate","check","fix","parser","malformed","invalid","broken","llm","ia","ai","chatgpt","gpt","openai","anthropic","claude","llama","deepseek","mistral","gemini","groq","qwen","grok","xai","o1","o3"],"description":"A robust utility to repair JSON strings - fix malformed or broken JSON, especially from LLM output like ChatGPT.","maintainers":[{"name":"sebog33","email":"sebastien@digiteld.com"}],"readme":"# @toolsycc/json-repair\n\n> A small but powerful utility to repair broken JSON strings — especially useful when dealing with LLM output or hand-written JSON.  \n> Need to repair JSON? This tool automatically fixes malformed or broken JSON structures with a single function call.\n> ✅ Works seamlessly with both **TypeScript** and **JavaScript** (ESM & CommonJS).\n\n## Features\n\n- Fixes:\n  - Unquoted keys\n  - Unquoted string values\n  - Trailing commas\n  - Invalid literals (NaN, undefined, Infinity)\n  - Capitalized literals (True, False, Null)\n  - Single quotes\n  - Missing closing braces\n  - Misplaced quotes inside strings\n  - LLM code blocks (e.g. ```json ... ```)\n  - LLM JSON extraction (e.g. `The result is: {...}`)\n- Option to return a string or JS object\n- ASCII escaping (e.g. `Café` → `Caf\\u00e9`)\n- Safe fallback mode\n\n## Install\n\n```bash\npnpm add @toolsycc/json-repair\n```\n\nOr with npm:\n\n```bash\nnpm install @toolsycc/json-repair\n```\n\n## Example usage\n\n### 🟦 TypeScript\n```ts\nimport { repairJson } from '@toolsycc/json-repair';\n\nconst input = `{name: Seb, age: 42,}`;\nconst repaired = repairJson(input);\nconsole.log(repaired);\n// → {\"name\":\"Seb\",\"age\":42}\n```\n\n### 🟨 JavaScript (CommonJS)\n```js\nconst { repairJson } = require('@toolsycc/json-repair');\n\nconsole.log(repairJson('{name: Seb, age: 42,}'));\n```\n\n### 🟩 JavaScript (ESM)\n```js\nimport { repairJson } from '@toolsycc/json-repair';\n\nconsole.log(repairJson('{name: Seb, age: 42,}'));\n```\n\n## Options\n\n| Option         | Type     | Default | Description |\n|----------------|----------|---------|-------------|\n| `extractJson`  | boolean  | `false` | Extracts the first JSON block from surrounding text (useful for LLM output) |\n| `encodeAscii`  | boolean  | `false` | Escapes non-ASCII characters (`é` → `\\u00e9`) |\n| `returnObject` | boolean  | `false` | If true, returns a JS object instead of a JSON string |\n| `logging`      | boolean  | `false` | Enables console logs of each transformation step |\n| `safeMode`     | boolean  | `false` | If true, throws a friendly error instead of crashing on unrecoverable input |\n\n## Examples\n\n| Input                               | Output                                  |\n|------------------------------------|------------------------------------------|\n| `{name: Seb}`                      | `{\"name\":\"Seb\"}`                        |\n| `{user: {name: Seb, age: 30}}`     | `{\"user\":{\"name\":\"Seb\",\"age\":30}}`      |\n| `{value: NaN}`                     | `{\"value\":null}`                        |\n| `'{\"text\": \"Café\"}'` + `encodeAscii: true` | `{\"text\":\"Caf\\u00e9\"}`           |\n| `Hello!\\n\\n\\\\`\\\\`\\\\`json\\n{name: Seb}`   | `{\"name\":\"Seb\"}`                        |\n\n## Live demonstration\n\nTry it: [Toolsy](https://www.toolsy.cc/tools/json/analyze)\n\n## Motivation\n\nThis package was designed to help deal with **malformed JSON**, especially the kind you get from LLMs like ChatGPT and OpenAI APIs when asking for `json` output.\nThis package is ideal if you're looking to **repair JSON**, **fix malformed JSON**, or **sanitize AI-generated output**.\nIt can also be used to quickly recover and parse broken logs or hand-crafted config files.\n\n## Author\n\nMade by [@Sebog33](https://github.com/Sebog33)  \nFollow [Toolsy](https://www.toolsy.cc) for more tiny dev-focused utilities.\n\n## License\n\nMIT\n","readmeFilename":"README.md"}