Detect the format and validate
validate_autoDetects whether a payload is JSON, YAML, XML or CSV, then validates it.
Use this when you have a blob of text and do not know what it is — a file with no extension, a clipboard paste, a response body with an unhelpful content type, or a config file whose format you would otherwise have to guess.
Detection is structural and the reason is always returned, so the assumption is visible rather than hidden: a leading < is XML, a leading { or [ is JSON, a %YAML directive or key: value lines are YAML, and a consistent delimiter count across multiple lines is CSV. JSON is checked before YAML on purpose, because JSON is a strict subset of YAML 1.2 and every JSON document would otherwise be ambiguous.
If the detected format does not validate but JSON or XML does, the result is corrected and detection.corrected is true. Only those two can win a correction, because only they have decisive grammars — CSV will read almost any text as a valid single-column file, so "it validates as CSV" is not evidence, and allowing it would silently reinterpret broken JSON as fine.
Prefer the format-specific tool when you already know the format: it skips detection and cannot be corrected out from under you.
Input: input, the raw text. Up to 1,000,000 bytes.
Returns: valid (no errors), parseable (whether a conforming parser would accept it — deliberately separate, because a duplicate key parses fine and still means two different things), a diagnostics array where each entry has a 1-based line and column, a stable rule code, a message, an excerpt showing the offending line with a caret under the column, a fixHint, and blocksParse; plus counts and format-specific stats. Rule codes are stable and safe to branch on; messages are not. Additionally detection with the chosen format, the reason in one sentence, and corrected.
Safety: nothing is resolved, fetched or expanded. External XML entities are reported, never retrieved; alias bombs are detected without being expanded; no schema or DTD is fetched over the network. Payloads are validated in memory and never stored.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input | Yes | The raw document text, not a parsed object — the findings are properties of the text. Up to 1,000,000 bytes. |