Tabular to JSON
tabular_to_jsonConvert messy tabular text into clean, typed JSON rows. Auto-detects CSV, TSV, or a Markdown table and returns one JSON object per row plus an inferred column/type summary. Pure deterministic compute — no network or model calls.
What it handles: delimiter sniffing (comma/semicolon/tab/pipe), quoted fields with embedded commas and newlines, BOM, ragged rows (padded/truncated), Markdown separator rows and escaped pipes, header auto-detection, and per-column type inference (integer/number/boolean/null/string).
When to use: you have CSV/TSV/Markdown-table text (often emitted by tools or LLMs) and want structured, typed rows — optionally validated/coerced against a JSON Schema.
When NOT to use: the data is already clean JSON, or it is HTML/xlsx/binary (not supported).
Args:
input (string, required): raw tabular text.
format ("auto"|"csv"|"tsv"|"markdown", default "auto"): force a format or auto-detect.
hasHeader ("auto"|"true"|"false", default "auto"): whether the first row is a header.
inferTypes (boolean, default true): coerce cells to number/integer/boolean/null; else keep strings.
schema (object, optional): JSON Schema (draft 2020-12) to validate/coerce each row object against.
Returns structuredContent: { "ok": boolean, // false if the input cannot be parsed as a table "format": "csv"|"tsv"|"markdown", "columns": [{ "name": string, "type": string }], "rows": [{ ... }], // one object per row, keyed by column name "rowCount": number, "changed": boolean, // true if any normalization/coercion happened "errors": string[], // actionable messages when ok is false "repairs": string[] // description of each normalization applied }
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input | Yes | Raw tabular text: a CSV/TSV block or a Markdown table. | |
| format | No | Force a parser or auto-detect (default 'auto'). | auto |
| schema | No | Optional JSON Schema (draft 2020-12) to validate/coerce each row object against. | |
| hasHeader | No | Whether the first row is a header. 'auto' uses a heuristic. | auto |
| inferTypes | No | When true (default), infer cell types (number/integer/boolean/null); else keep strings. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | Yes | True if the input parsed as a table (and every row is schema-valid when a schema was given). | |
| rows | Yes | One JSON object per data row, keyed by column name. | |
| errors | Yes | Actionable error messages when ok is false (empty when ok is true). | |
| format | Yes | The detected/used format. | |
| changed | Yes | True if any normalization or coercion changed the input. | |
| columns | Yes | Inferred column names and types. | |
| repairs | Yes | Human-readable description of each normalization applied. | |
| rowCount | Yes | Number of data rows returned. |