{
  "slug": "regex-to-json",
  "name": "gizza-ai/regex-to-json",
  "version": "0.1.0",
  "title": "Regex to JSON — Parse Text Lines into Structured JSON — gizza.ai",
  "description": "Parse each line of text with a named-capture regex and turn it into structured JSON — group names become keys. Type coercion, NDJSON output, in your browser.",
  "tags": [
    "regex to json",
    "log to json",
    "named capture groups",
    "parse logs",
    "text to json",
    "ndjson",
    "structured data",
    "regex parser"
  ],
  "category": "data",
  "urls": {
    "page": "https://gizza.ai/tools/regex-to-json/",
    "markdown": "https://gizza.ai/tools/regex-to-json/index.md",
    "descriptor": "https://gizza.ai/tools/regex-to-json/tool.json",
    "deep_link_example": "https://gizza.ai/tools/regex-to-json/?text=10.0.0.5%20GET%20%2Findex.html%20200%20512%0A10.0.0.9%20POST%20%2Fapi%2Flogin%20401%2087&pattern=%28%3F%3Cip%3E%5CS%2B%29%20%28%3F%3Cmethod%3E%5BA-Z%5D%2B%29%20%28%3F%3Cpath%3E%5CS%2B%29%20%28%3F%3Cstatus%3E%5Cd%7B3%7D%29%20%28%3F%3Cbytes%3E%5Cd%2B%29&ignore_case=true&all_matches=true&unmatched=skip&coerce_types=true&output=json"
  },
  "cli": "gizza tool regex-to-json \"10.0.0.5 GET /index.html 200 512\n10.0.0.9 POST /api/login 401 87\" 'pattern=(?<ip>\\S+) (?<method>[A-Z]+) (?<path>\\S+) (?<status>\\d{3}) (?<bytes>\\d+)'",
  "tool": {
    "description": "Parse each line of text with a regular expression that uses NAMED capture groups ((?<name>…) or (?P<name>…), Rust regex syntax) and emit one structured JSON object per line (or per match, with all_matches), keyed by group name in pattern order. Choose what happens to non-matching lines via unmatched (skip them, keep them as {\"_raw\": line}, or fail), optionally coerce number/boolean/null-looking captures into real JSON types with coerce_types, and pick the output shape with output (pretty JSON array, compact array, or NDJSON). Groups that did not participate in a match are emitted as null. Blank lines are ignored; input is capped at 1 MB. Runs locally.",
    "parameters": {
      "additionalProperties": false,
      "properties": {
        "all_matches": {
          "default": false,
          "description": "Emit one JSON object for every match on a line instead of only the first — a line with three matches yields three objects (useful for key=value pairs).",
          "type": "boolean"
        },
        "coerce_types": {
          "default": false,
          "description": "Convert captures that look like plain numbers (42, -3.14), true/false, or null into real JSON types instead of strings. Values with leading zeros (007) or scientific notation stay strings.",
          "type": "boolean"
        },
        "ignore_case": {
          "default": false,
          "description": "Match case-insensitively.",
          "type": "boolean"
        },
        "output": {
          "default": "json",
          "description": "Output shape: 'json' = pretty-printed JSON array, 'compact' = single-line JSON array, 'ndjson' = one JSON object per line (JSON Lines).",
          "enum": [
            "json",
            "compact",
            "ndjson"
          ],
          "type": "string"
        },
        "pattern": {
          "description": "Regular expression (Rust regex syntax) with NAMED capture groups — (?<name>…) or (?P<name>…). Each named group becomes a JSON key, e.g. (?<level>[A-Z]+) (?<message>.*). Numbered groups are ignored.",
          "type": "string"
        },
        "text": {
          "description": "The text to parse, one record per line (log lines, exports, command output). Blank lines are ignored; CRLF line endings are handled. Max 1 MB.",
          "type": "string"
        },
        "unmatched": {
          "default": "skip",
          "description": "What to do with non-blank lines the pattern does not match: 'skip' drops them, 'keep' emits {\"_raw\": \"<line>\"} so no data is lost, 'fail' stops with an error naming the first unmatched line.",
          "enum": [
            "skip",
            "keep",
            "fail"
          ],
          "type": "string"
        }
      },
      "required": [
        "text",
        "pattern"
      ],
      "type": "object"
    }
  }
}