Catalog/llm-json-extract

LLM

Extract JSON from prose API

Pulls every balanced JSON object/array embedded in free-form LLM text (handling nested braces and fenced blocks), repairs and parses each, and returns all blocks with their positions plus the first value. Answers 'how do I get the JSON out of a chatty model answer?', 'which JSON blocks are in this text?'.

Price$0.02per request
MethodPOST
Route/v1/llm/json-extract
StatusLive
MIME typeapplication/json
Rate limit120/minute
Cache0s public
llmjsonextractparseprosestructured-outputscanagent
API URLhttps://x402.hexl.dev/v1/llm/json-extract
Integration docs
Example request
{
  "text": "before {\"a\":1} mid [1,2,3] end"
}
Example response
{
  "count": 2,
  "blocks": [
    {
      "start": 7,
      "end": 14,
      "raw": "{\"a\":1}",
      "value": {
        "a": 1
      }
    },
    {
      "start": 19,
      "end": 26,
      "raw": "[1,2,3]",
      "value": [
        1,
        2,
        3
      ]
    }
  ],
  "first": {
    "a": 1
  }
}
Input schema
{
  "type": "object",
  "required": [
    "text"
  ],
  "properties": {
    "text": {
      "type": "string",
      "examples": [
        "before {\"a\":1} mid [1,2,3] end"
      ]
    },
    "mode": {
      "type": "string",
      "enum": [
        "first",
        "all"
      ],
      "default": "all"
    }
  }
}
Output schema
{
  "type": "object",
  "additionalProperties": true
}