What is your goal?
Strip leading json and trailing markdown code fences from an Anthropic Claude API text response, so it can be parsed by the Parse JSON module.
What is the problem & what have you tried?
I’m processing news articles through the Anthropic Claude module, then trying to parse the response as JSON using the Parse JSON module. The issue: Claude’s text response is sometimes wrapped in markdown code fences (json ... ), which breaks Parse JSON with “Source is not valid JSON. Code: DataError”.
I added a system prompt instruction telling Claude not to use markdown formatting, but the wrapper still appears occasionally.
What I’ve tried to strip the fences using replace():
- Typed directly into Parse JSON’s “JSON string” field as text with an inserted variable chip:
replace(replace(10. Text Response; “json"; ""); "”; “”)
Result: the entire expression