[BUG] --output-format json result field contains invalid JSON when model uses unescaped " in string values

Resolved 💬 3 comments Opened May 3, 2026 by willert Closed May 7, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Steps to reproduce:

claude -p --output-format json \
'Return ONLY this JSON array exactly: [{"title":"Primary CTA „Kostenlos teilnehmen\" auf Stage"}]'

Observe that the result field in the JSON envelope contains a bare ASCII " (U+0022) inside a string value (the closing German
quotation mark), making the result unparseable as JSON.

Expected: When --output-format json is used, the result field should always contain a string that, if the model was asked to
produce JSON, is valid and parseable — either by the CLI re-encoding the content, or by the model consistently following JSON
escaping rules.

Actual: "result":"...\u201eKostenlos teilnehmen\" auf Stage..." — the " after teilnehmen is U+0022 without a preceding \,
breaking any downstream json.Unmarshal of the result.

Version: claude 2.1.126 (Claude Code)

Workaround: Scanning the result for " characters that are not followed by a JSON structural token (,, }, ], :) and escaping
them.

---
The version number is 2.1.126 — you can confirm with claude --version before submitting.

What Should Happen?

claude cli should always produce valid JSON when --output-format json is used

Error Messages/Logs

Steps to Reproduce

claude -p --output-format json \
'Return ONLY this JSON array exactly: [{"title":"Primary CTA „Kostenlos teilnehmen\" auf Stage"}]'

Observe that the result field in the JSON envelope contains a bare ASCII " (U+0022) inside a string value (the closing German
quotation mark), making the result unparseable as JSON.

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.126

Platform

Other

Operating System

Ubuntu/Debian Linux

Terminal/Shell

Xterm

Additional Information

_No response_

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗