{{ result.formatted }}
{{ result.json }}
{{ result.stats.keys }}
{{ result.stats.objects }}
{{ result.stats.arrays }}
{{ result.stats.scalars }}
{{ result.stats.comments }}
{{ result.stats.lines }}
ℹ️ About YAML Formatter
YAML Formatter/Validator cleans up YAML configuration files, checks parser errors, and converts structured YAML to JSON when you need a machine-readable view. YAML is defined by the YAML 1.2.2 specification as an indentation-based serialization language for mappings, sequences, and scalar values, with JSON compatibility described alongside RFC 8259 JSON.
Use it to pretty-print Kubernetes manifests, Docker Compose files, CI pipelines, Ansible inventories, OpenAPI fragments, Home Assistant automations, and other YAML documents before committing them to version control. Consistent two- or four-space indentation makes nested lists and mappings easier to review:
services:
api:
image: nginx:1.27
ports:
- "8080:80"
The validator helps catch common syntax mistakes before a deployment tool or parser rejects the file.
- Indentation errors: missing spaces, unexpected nesting, and mixed tab/space indentation.
- Structure checks: mappings, sequences, block scalars, comments, and multi-document separators such as
---. - Conversion checks: optional YAML-to-JSON output for data that must be consumed by JSON-only APIs.
- Normalization: key sorting, comment removal, and consistent list style when preparing generated config.
YAML parsers can differ around implicit scalar types, duplicate keys, anchors, aliases, merge keys, and custom tags. If a document is meant for a specific runtime, also validate it with that tool's schema or CLI. For example, Kubernetes configuration and OpenAPI documents need application-level validation beyond generic YAML syntax.
Treat untrusted YAML as data, not code. Some language-specific YAML loaders support object construction or custom tags that can be dangerous in backend applications; the OWASP Deserialization Cheat Sheet explains why unsafe deserialization should be avoided. This formatter is useful for readability and parser feedback, but it cannot prove that secrets are safe to share, that a deployment will succeed, or that a schema-specific value is correct.
API Usage Example:
POST /api/tools/webdev/yaml-formatter
Content-Type: application/json
{
"yaml": "name: example\nversion: 1.0\nitems:\n - id: 1\n value: test",
"format": true,
"validate": true,
"indentSize": 2,
"arrayStyle": "block",
"objectStyle": "block",
"convertToJson": false,
"sortKeys": false,
"removeComments": false,
"addDocumentSeparator": false
}