{"id":"json-text-repair","version":"1.0.0","description":"Repair six common lexical JSON defects (comments, trailing commas, single quotes, ...) and list every edit made.","supported_operations":["repair broken json from an llm","fix trailing commas in json","convert single quoted json to valid json","quote unquoted keys in a json object","strip comments from json text","replace python True False None in json","תיקון פלט נתונים שבור של מודל שפה"],"unsupported_operations":["close truncated or unbalanced JSON, or insert missing commas or colons","strip Markdown code fences, prose or other wrappers around JSON","choose between duplicate member names","convert NaN, Infinity, undefined, hexadecimal or leading-zero numbers"],"semantics":["Grammar is ECMA-404 2nd edition / RFC 8259. Exactly six defects are repaired: a leading U+FEFF byte order mark (removed), // and /* */ comments (removed), a comma directly before ] or } of a non-empty container (removed), single-quoted strings (rewritten as JSON strings), unquoted identifier keys [A-Za-z_$][A-Za-z0-9_$]* (quoted), and Python True/False/None in value position (true/false/null).","Everything else is refused with invalid_input and details {reason, offset}: missing or doubled commas, unbalanced or truncated text, unknown identifiers (NaN, Infinity, undefined), invalid numbers, invalid escapes, raw control characters in strings, unquoted keys that are literal names, extra top-level content, empty text.","Duplicate member names are refused (reason duplicate_key) at every nesting level, compared after decoding, so \"a\", 'a', a and \"\\u0061\" are the same name (RFC 8259 section 4: behavior with duplicate names is unpredictable).","Edits are listed in text order with code point offsets: start/end in the input, repaired_start/repaired_end in the output, original and replacement text. Bytes outside edits are copied unchanged, including whitespace and string contents.","Single-quoted strings keep their content: \\' becomes ', a raw \" becomes \\\", other JSON escapes are kept as written. Key names are not normalized.","Limits: text at most 65536 UTF-8 bytes (checked first), nesting depth at most 64, at most 256 edits; each overflow is limit_exceeded."],"limits":{"max_text_bytes":65536,"max_depth":64,"max_edits":256},"pricing":{"status":"unpriced","charge_usd":null},"input_schema":{"type":"object","additionalProperties":false,"required":["text"],"properties":{"text":{"type":"string","description":"JSON-like text, at most 65536 UTF-8 bytes."}}},"output_schema":{"type":"object","additionalProperties":false,"required":["repaired","changed","edit_count","edits"],"properties":{"repaired":{"type":"string","minLength":1},"changed":{"type":"boolean"},"edit_count":{"type":"integer","minimum":0,"maximum":256},"edits":{"type":"array","maxItems":256,"items":{"type":"object","additionalProperties":false,"required":["kind","start","end","original","replacement","repaired_start","repaired_end"],"properties":{"kind":{"type":"string","enum":["byte_order_mark","comment","trailing_comma","single_quoted_string","unquoted_key","python_literal"]},"start":{"type":"integer","minimum":0,"maximum":131072},"end":{"type":"integer","minimum":0,"maximum":131072},"original":{"type":"string","minLength":1},"replacement":{"type":"string"},"repaired_start":{"type":"integer","minimum":0,"maximum":131072},"repaired_end":{"type":"integer","minimum":0,"maximum":131072}}}}}},"examples":[{"input":{"text":"{name: 'Ada', active: True,}"},"output":{"repaired":"{\"name\": \"Ada\", \"active\": true}","changed":true,"edit_count":5,"edits":[{"kind":"unquoted_key","start":1,"end":5,"original":"name","replacement":"\"name\"","repaired_start":1,"repaired_end":7},{"kind":"single_quoted_string","start":7,"end":12,"original":"'Ada'","replacement":"\"Ada\"","repaired_start":9,"repaired_end":14},{"kind":"unquoted_key","start":14,"end":20,"original":"active","replacement":"\"active\"","repaired_start":16,"repaired_end":24},{"kind":"python_literal","start":22,"end":26,"original":"True","replacement":"true","repaired_start":26,"repaired_end":30},{"kind":"trailing_comma","start":26,"end":27,"original":",","replacement":"","repaired_start":30,"repaired_end":30}]}},{"input":{"text":"[1, 2, 3] // ids"},"output":{"repaired":"[1, 2, 3] ","changed":true,"edit_count":1,"edits":[{"kind":"comment","start":10,"end":16,"original":"// ids","replacement":"","repaired_start":10,"repaired_end":10}]}},{"input":{"text":"{\"a\": 1}"},"output":{"repaired":"{\"a\": 1}","changed":false,"edit_count":0,"edits":[]}}],"execute_url":"/v1/tools/json-text-repair/versions/1.0.0/execute"}