extract_json_from_text
Extract clean JSON objects from messy LLM responses by stripping code fences, comments, and surrounding text, returning the first parseable value.
Instructions
Extract and parse a JSON value embedded in messy LLM output. Strips ```json fences, leading/trailing prose, code comments, and tolerates other LLM-isms. Returns the first parseable value and where in the text it started.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"text": "<text>"
},
"name": "extract_json_from_text"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | Free-form text that contains a JSON value somewhere inside. |