BroadRouter

LLM JSON output validator

Updated

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

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

Examples:
Repairs to allow

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

Validate against a JSON Schema (optional)

A schema, a json_schema object or a whole response_format.

    Structured output on BroadNet models

    Whether BroadNet's developer reference lists structured output for each chat model
    ModelModel IDStructured output in BroadNet's docs
    DeepSeek V4.1 Flashbroadnet/deepseek-v4.1-flashNot listed: prompt for JSON and validate
    GLM 5.3broadnet/glm-5.3Listed
    Qwen3.8 27Bbroadnet/qwen3.8-27bListed
    BroadNet Gemma 4 VL 26Bbroadnet/gemma-4-26b-a4bNot 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.

    Report a wrong price or number (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 seeCauseFix at the source
    ```json or “Here is…” around itThe model formats its answer for a chat windowUse structured output where the model supports it, or say “Reply with only the JSON object”
    ,} or ,]Trailing comma, valid in JavaScript but not JSONRepair is safe; a schema-constrained mode prevents it
    'key', “key” or key:Python or JavaScript habits, or curly quotesShow a JSON example in the prompt; repair is safe
    True, None, NaNPython or JavaScript literalsRepair maps them to true, null
    Ends mid-string, brackets left openThe reply hit max_tokens (finish_reason: "length")Raise max_tokens; on reasoning models leave room for reasoning; split long lists
    Parses, but fields are wrongValid JSON, wrong shapeValidate 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 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

    Read as MarkdownAsk ChatGPTAsk ClaudeAsk Perplexity