---
title: "LLM JSON output validator: find, fix and check model JSON"
description: "Paste LLM output to extract its JSON, see parse errors by line and column, repair fences, trailing commas and quotes, spot cut-off output and check a schema."
url: https://broadrouter.com/tools/llm-json-output-validator/
lang: en
updated: 2026-11-15
publisher: BroadRouter (a BroadNet site); API by BroadNet Inference, https://inference.broadnet.ai
---

# LLM JSON output validator

Updated 2026-11-15

**In short:** Five common causes of invalid JSON from an LLM: a code fence or prose around it, trailing commas, single or curly quotes, unquoted keys, or output cut off at max\_tokens (finish\_reason "length"). Paste the output to find the error by line and column, apply safe repairs and validate it against your JSON Schema.

Free, no sign-up, runs in your browser: nothing you type is sent anywhere.

Model output

Model output

Paste the reply as it came back. Stays in your browser.

Examples:

Repairs to allow

 Single and curly quotes Unquoted keys Trailing commas Missing commas Comments True, None, NaN, undefined Line breaks inside strings Close cut-off output (loses data)

Code fences, reasoning blocks and text around the JSON are always set aside.

### Validate against a JSON Schema (optional)

JSON Schema

A schema, a `json_schema` object or a whole `response_format`.

**JSON** 

## Structured output on BroadNet models

Whether BroadNet's developer reference lists structured output for each chat model
| Model | Model ID | Structured output in BroadNet's docs |
| --- | --- | --- |
| DeepSeek V4.1 Flash | `broadnet/deepseek-v4.1-flash` | Not listed: prompt for JSON and validate |
| GLM 5.3 | `broadnet/glm-5.3` | Listed |
| Qwen3.8 27B | `broadnet/qwen3.8-27b` | Listed |
| BroadNet Gemma 4 VL 26B | `broadnet/gemma-4-26b-a4b` | Not listed: prompt for JSON and validate |

From BroadNet's developer reference, checked 2026-11-15. The reference does not say which `response_format` types each model accepts; test on yours.

[Write a schema](https://broadrouter.com/tools/json-schema-generator/) · [Get started](https://inference.broadnet.ai/account/?utm_source=broadrouter&utm_medium=referral&utm_campaign=tools-llm-json-output-validator&utm_content=tool-account) ·

[Report a wrong price or number](mailto:info@broadnet.ai?subject=Wrong%20price%20or%20number%20on%20LLM%20JSON%20output%20validator&body=Page%3A%20https%3A%2F%2Fbroadrouter.com%2Ftools%2Fllm-json-output-validator%2F%0A%0AWhat%20looks%20wrong%20(model%2C%20figure%20shown%2C%20correct%20figure%20and%20a%20source%20link%20if%20you%20have%20one)%3A%0A) (email to info@broadnet.ai, with this page's link and your inputs filled in).

## How it works

1.  Paste the model's reply as it came back, with any code fence or surrounding text. Or load one of the examples.
2.  Read the verdict: valid as-is, or the first error with its line and column, and whether the output looks cut off.
3.  Choose which repairs to allow. The repaired JSON is parsed again, and you can copy it raw or formatted.
4.  Optionally paste a JSON Schema, or a whole `response_format` object, to check fields, types and required keys.

## Why model JSON breaks, and the fix for each

| What you see | Cause | Fix at the source |
| --- | --- | --- |
| ` ```json ` or “Here is…” around it | The model formats its answer for a chat window | Use structured output where the model supports it, or say “Reply with only the JSON object” |
| `,}` or `,]` | Trailing comma, valid in JavaScript but not JSON | Repair is safe; a schema-constrained mode prevents it |
| `'key'`, `“key”` or `key:` | Python or JavaScript habits, or curly quotes | Show a JSON example in the prompt; repair is safe |
| `True`, `None`, `NaN` | Python or JavaScript literals | Repair maps them to `true`, `null` |
| Ends mid-string, brackets left open | The reply hit `max_tokens` (`finish_reason: "length"`) | Raise `max_tokens`; on reasoning models leave room for reasoning; split long lists |
| Parses, but fields are wrong | Valid JSON, wrong shape | Validate against a schema and retry with the errors in the prompt |

## A safe parsing loop

1.  Check `finish_reason` first. If it is `"length"`, do not repair: retry with a larger `max_tokens`.
2.  Strip a code fence or surrounding text, then parse strictly.
3.  On failure, apply only value-preserving repairs and parse again.
4.  Validate against your JSON Schema. On errors, send them back to the model once, then give up and log the item.

Repairs that keep every value (quotes, commas, keys, comments) are safe to automate. Repairs that guess, such as closing cut-off output, belong in a debugging session, not in production code.

## What this validator does not do

It checks a common subset of JSON Schema 2020-12 (with draft-07 `definitions`), not every keyword. Remote `$ref` URLs, `dependentRequired`, `if`/`then`/`else` and `unevaluatedProperties` are reported as not checked. Strict structured-output modes add their own rules, which the [JSON schema generator](https://broadrouter.com/tools/json-schema-generator/) checks.

## Questions

### Why does my LLM return invalid JSON?

The common causes: the model wrapped the JSON in a code fence or a sentence, left a trailing comma, used single or curly quotes, wrote keys without quotes, or ran out of tokens mid-object. Python-style `True` and `None`, and comments, also turn up. The validator names the error and the line and column where it starts.

### How can I tell if the JSON was cut off by max\_tokens?

Truncated output ends inside a string or with brackets still open. Check the response too: OpenAI's API reference defines `finish_reason: "length"` as the maximum number of tokens being reached (checked 2026-11-15). On reasoning models such as DeepSeek V4.1 Flash, GLM 5.3, Qwen3.8 27B, BroadNet's docs say reasoning counts toward `max_tokens`, so a small limit can cut the JSON short.

### Is it safe to repair LLM JSON automatically?

Quote, comma, comment and key fixes keep every value, so they are generally safe, but check the result against your schema. Closing cut-off output is different: everything after the cut is lost, so the tool leaves that repair off by default. Raise `max_tokens` and request the item again instead.

### Which BroadNet models support structured output?

BroadNet's developer reference lists structured output for GLM 5.3 and Qwen3.8 27B (checked 2026-11-15). It does not document which `response_format` types they accept, so send a test request. For other models, ask for JSON in the prompt, show an example, validate every reply and retry on failure.

### Which JSON Schema keywords does the validator check?

type (including integer and type lists), properties, required, additionalProperties, patternProperties, propertyNames, items, prefixItems, contains, enum, const, string length, pattern, common formats, numeric bounds, multipleOf, array and object size, uniqueItems, allOf, anyOf, oneOf, not and local $ref. Keywords it does not check are listed, not passed silently.

### Is my output sent anywhere?

No. Parsing, repair and validation run in your browser, and nothing you paste is stored in the page address or sent to a server. Close the tab and it is gone.

## Go deeper

-   [How to fix invalid JSON from an LLM](https://broadrouter.com/blog/fix-invalid-json-from-llm/)
-   [JSON mode vs json\_schema](https://broadrouter.com/blog/structured-output-json-schema/)
-   [JSON schema generator for structured output](https://broadrouter.com/tools/json-schema-generator/)
-   [max\_tokens calculator for reasoning models](https://broadrouter.com/tools/reasoning-token-budget/)
-   [Why reasoning models return empty replies](https://broadrouter.com/guides/reasoning-tokens-empty-response/)
-   [Glossary: structured output](https://broadrouter.com/glossary/structured-output/)

## More free tools

-   [**LLM API cost calculator**Price a workload on every model at once, with cache hits, reasoning and a flat-plan check.](https://broadrouter.com/tools/llm-api-cost-calculator/)
-   [**Speech-to-text cost calculator**Hours, calls or voice notes to a monthly transcription bill, against your current provider.](https://broadrouter.com/tools/speech-to-text-cost-calculator/)
-   [**LLM token counter**Exact token counts with each model's real tokenizer, with a token view and cost.](https://broadrouter.com/tools/token-counter/)
-   [**Arabic token counter**Arabic vs English token counts per tokenizer: the "Arabic tax" in tokens and money.](https://broadrouter.com/tools/arabic-token-counter/)
-   [**Tokens to words converter**Tokens ↔ words ↔ characters ↔ pages, by language and content type.](https://broadrouter.com/tools/tokens-to-words/)
-   [**Context window calculator**Will it fit? Window used per model, room left for output, cost to send.](https://broadrouter.com/tools/context-window-calculator/)
-   [**Flat-rate vs per-token LLM cost calculator**Break-even between an unlimited plan and paying per token, per agent.](https://broadrouter.com/tools/flat-rate-vs-per-token-calculator/)
-   [**Prompt caching savings calculator**Bill with and without caching, by prefix share and hit rate.](https://broadrouter.com/tools/prompt-caching-calculator/)
-   [**Image token calculator**Tokens and cost per image under each model's documented rule. Drop an image; nothing is uploaded.](https://broadrouter.com/tools/image-token-calculator/)
-   [**Self-hosting vs API cost calculator**GPU rental against your current API and BroadNet per-token and flat-plan prices: cost per 1M tokens and break-even volume.](https://broadrouter.com/tools/self-hosting-vs-api-calculator/)
-   [**Embedding cost calculator**Index, update and query costs for a corpus at OpenAI, Google, Voyage, Mistral and Jina list prices.](https://broadrouter.com/tools/embedding-cost-calculator/)
-   [**LLM rate limit and concurrency calculator**Which limit binds first: RPM, TPM or concurrency, with Little's law.](https://broadrouter.com/tools/llm-rate-limit-calculator/)
-   [**JSON schema generator for LLM structured output**Sample JSON to strict schema, Pydantic, Zod and a ready request.](https://broadrouter.com/tools/json-schema-generator/)
-   [**OpenAI-compatible API request builder**One request, copied as curl, Python, Node or the OpenAI SDKs.](https://broadrouter.com/tools/api-request-builder/)
-   [**Audio file splitter for speech-to-text limits**Chunk count, overlap and copy-ready ffmpeg commands to fit a transcription file-size limit.](https://broadrouter.com/tools/audio-splitter-ffmpeg/)
-   [**Agent run cost estimator**Context growth per step, total tokens and cost of one agent run, with a DeepSeek session comparison.](https://broadrouter.com/tools/agent-run-cost-estimator/)
-   [**OpenAI to BroadNet migration helper**Paste OpenAI SDK code; get base URL, key and model edits, a diff and the checks that remain.](https://broadrouter.com/tools/openai-to-broadnet-migration/)
-   [**Arabic text normalizer**Tashkeel, tatweel, alef, ya, ta marbuta, digits and invisible characters, with a matching Python function.](https://broadrouter.com/tools/arabic-text-normalizer/)
-   [**RAG chunking calculator**Chunks, embedding tokens, input per query, context check and monthly LLM cost for a RAG pipeline.](https://broadrouter.com/tools/rag-chunking-calculator/)
-   [**max\_tokens calculator for reasoning models**Answer length + reasoning budget + margin = a max\_tokens that does not cut the answer off.](https://broadrouter.com/tools/reasoning-token-budget/)
-   [**LLM batch job planner**Run time, binding limit, cost per model and the flat sessions needed to finish a big job by a deadline.](https://broadrouter.com/tools/llm-batch-job-planner/)
-   [**Prompt token diff**Two prompt versions side by side: changed lines, exact token delta and the monthly cost difference.](https://broadrouter.com/tools/prompt-token-diff/)

Try it on your real workload. New accounts start with $5 of credit for Gemma and transcription. DeepSeek, GLM and Qwen3.8 need a top-up.

[Get started](https://inference.broadnet.ai/account/?utm_source=broadrouter&utm_medium=referral&utm_campaign=tools-llm-json-output-validator&utm_content=page-cta) ·

**Sources**

-   [BroadNet Inference machine-readable prices (pricing.json)](https://inference.broadnet.ai/pricing.json?utm_source=broadrouter&utm_medium=referral&utm_campaign=tools-llm-json-output-validator&utm_content=sources)
-   [BroadNet Inference API reference: structured output listed for GLM 5.3 and Qwen3.8 27B; reasoning counts toward max\_tokens (checked 2026-11-15)](https://inference.broadnet.ai/docs?utm_source=broadrouter&utm_medium=referral&utm_campaign=tools-llm-json-output-validator&utm_content=sources)
-   [OpenAI API reference, chat completions: finish\_reason "length", response\_format json\_object and json\_schema (checked 2026-11-15)](https://developers.openai.com/api/reference/resources/chat/subresources/completions/methods/create)
-   [RFC 8259, the JSON data interchange format: grammar with no trailing commas, comments or single quotes (checked 2026-11-15)](https://www.rfc-editor.org/rfc/rfc8259)
-   [JSON Schema 2020-12 validation vocabulary (checked 2026-11-15)](https://json-schema.org/draft/2020-12/json-schema-validation)
