webdev_yaml_formatter
Format, validate, and beautify YAML documents with optional JSON conversion. Detects parse errors, mixed indentation, and trailing whitespace. Can sort keys, strip comments, or add document separators.
Instructions
YAML Formatter and Validator. Format, validate, and beautify a YAML document, with optional conversion to JSON. Pretty-prints with a chosen indent, reports parse errors with line numbers, flags mixed-indentation and trailing-whitespace warnings, and can sort keys, strip comments, add document separators, or emit equivalent JSON. Use this for YAML; use webdev_json_formatter for JSON or webdev_xml_formatter for XML. Runs locally on the text you provide (read-only, non-destructive, contacts no external service) and is rate-limited to 60 requests/minute for anonymous callers. Returns the formatted YAML, optional JSON, a validity flag, error and warning lists, and structure statistics.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| yaml | Yes | YAML document to process. Must not be blank. | |
| format | No | Re-serialize (pretty-print) the parsed data; when false the original text is returned unchanged. | |
| validate | No | Parse the input to determine validity and collect warnings. | |
| indentSize | No | Spaces per indent level for the formatted output (UI offers 2, 4, or 8). | |
| arrayStyle | No | Sequence rendering: block (one item per line) or inline (flow style). | block |
| objectStyle | No | Mapping rendering: block (one key per line) or inline (flow style). | block |
| convertToJson | No | Also emit the data as 2-space-indented JSON in the json field. | |
| sortKeys | No | Recursively sort mapping keys alphabetically before output. | |
| removeComments | No | Drop lines that are YAML comments from the formatted output. | |
| addDocumentSeparator | No | Wrap output with a leading start marker and a trailing end marker. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| original | No | The submitted YAML, echoed back. | |
| formatted | No | The formatted YAML (or original text when format is false or parsing failed). | |
| json | No | Equivalent JSON when convertToJson is true, otherwise an empty string. | |
| isValid | No | Whether the input parsed as valid YAML. | |
| errors | No | Parse error messages (empty when valid). | |
| warnings | No | Non-fatal lint warnings with line numbers (mixed indentation, trailing whitespace). | |
| stats | No | Structure and size metrics for the document. |