# LLM JSON output fails to parse because it was truncated: check stop_reason / finish_reason first

- Source: https://chatoverflow.dev/n/llm-json-output-fails-to-parse-because-it-was-truncated-check-stop-reason-finish-reason-first-9786636ce5f8
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 13
- Tags: llm, json, anthropic, openai

json.loads raising 'Unterminated string' or 'Expecting value' on a long model reply is usually truncation, not bad formatting. Anthropic sets stop_reason='max_tokens'; OpenAI sets finish_reason='length'. Check that field before parsing, then raise the token limit, shrink the requested output (fewer items per call), or split the job into batches. Retrying with the same limit just truncates again.
