
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
ai-json-fixer
Advanced tools
A simple JSON parser designed to handle malformed JSON from Large Language Models
A simple JSON parser specifically designed to handle malformed JSON output from Large Language Models (LLMs) like GPT, Claude, and others.
code{"a": 1 "b": 2} and [1 2 3]npm install ai-json-fixer
import { LLMJSONParser } from 'ai-json-fixer';
const parser = new LLMJSONParser();
// Parse JSON from LLM output with markdown
const llmOutput = `Here's the data you requested:
\`\`\`json
{
"users": [
{"name": "Alice", "age": 30},
{"name": "Bob", "age": 25}
],
"total": 2
}
\`\`\`
This JSON contains the user information.`;
const result = parser.parse(llmOutput);
console.log(result);
// Output: { users: [...], total: 2 }
const input = `\`\`\`json\n{"key": "value"}\n\`\`\``;
const result = parser.parse(input); // { key: "value" }
const input = '{"message": "He said "hello" to me"}';
const result = parser.parse(input); // { message: 'He said "hello" to me' }
const input = '{"status": "ok"} The request was successful.';
const result = parser.parse(input); // { status: "ok" }
Multi-line JSON:
const input = `{
"name": "John"
"age": 30
}`;
const result = parser.parse(input); // { name: "John", age: 30 }
Single-line JSON:
// Objects
const input1 = '{"a": 1 "b": 2 "c": 3}';
const result1 = parser.parse(input1); // { a: 1, b: 2, c: 3 }
// Arrays
const input2 = '[1 2 3 4 5]';
const result2 = parser.parse(input2); // [1, 2, 3, 4, 5]
// Complex structures
const input3 = '[{"id": 1} {"id": 2}]';
const result3 = parser.parse(input3); // [{ id: 1 }, { id: 2 }]
LLMJSONParserparse<T>(input: string, options?: ParseOptions): T | nullParse JSON input with automatic fixing. Returns parsed object or null if parsing fails.
tryParse<T>(input: string, options?: ParseOptions): ParseResult<T>Parse with detailed results including applied fixes and confidence score.
interface ParseOptions {
mode?: 'strict' | 'standard' | 'aggressive';
stripMarkdown?: boolean;
trimTrailing?: boolean;
fixQuotes?: boolean;
addMissingCommas?: boolean;
trackFixes?: boolean;
throwOnError?: boolean;
maxFixAttempts?: number;
}
interface ParseResult<T> {
data: T | null;
fixes?: Fix[];
confidence?: number;
warnings?: string[];
}
# Install dependencies
npm install
# Run tests
npm test
# Build
npm run build
# Run examples
npx tsx examples/basic-usage.ts
MIT
FAQs
A simple JSON parser designed to handle malformed JSON from Large Language Models
The npm package ai-json-fixer receives a total of 920 weekly downloads. As such, ai-json-fixer popularity was classified as not popular.
We found that ai-json-fixer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.