Prompt

Why is Anthropic not returning valid JSON?

Artificial Intelligence / AI Platforms1 observationLast seen Oct 9, 2026

Latest observation

Oct 9, 2026OpenAI APIWeb search: off

Common reasons Anthropic outputs “almost JSON” instead of valid JSON:

  1. You didn’t force strict JSON mode

    • If you ask for JSON in plain text, the model may add markdown fences, comments, or trailing text.
    • Use a response format / tool schema if your API wrapper supports it.
  2. The prompt is ambiguous

    • If examples include prose, explanations, or code fences, the model may imitate that.
    • Be explicit: “Return only raw JSON. No markdown. No code fences. No extra text.”
  3. The schema is underspecified or conflicting

    • If you say “include optional fields” but also require all fields, the model may improvise.
    • Keep field names, types, and nesting very clear.
  4. The model is trying to be helpful

    • It may add natural-language clarifications before/after the JSON unless constrained.
  5. Streaming/parsing issues

    • Sometimes the model output is fine, but your client reads partial chunks or concatenates them incorrectly.
  6. Post-processing is altering the output

    • Middleware, logging, or templating may insert text around the JSON.
  7. The output is valid JSON in spirit, but not strict JSON

    • Common issues:
      • trailing commas
      • single quotes instead of double quotes
      • unescaped newlines in strings
      • comments
      • NaN/Infinity

How to fix it:

  • Use a strict JSON response mechanism if available.
  • Add a system prompt like:
    • “You must output only valid JSON, with no markdown or extra text.”
  • Provide a concrete schema and one minimal example.
  • Validate on the client side and retry if parsing fails.
  • Lower temperature if the model is being creative.

If you want, paste:

  1. your exact prompt,
  2. a sample response,
  3. and the API call code,

and I can tell you exactly why it’s breaking.

Brands

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.