Why use this converter
Smart parser
Handles block-style mappings, sequences, nested structures, quoted strings, flow collections, and comments. A subset of YAML 1.2 that covers 99% of real-world configs.
Type inference
YAML's untyped scalars are inferred to the most appropriate JSON type: integers, floats, booleans, null, or strings. Strings that look like numbers stay strings if quoted.
Output control
Choose 2-space, 4-space, or tab indentation. Optionally sort object keys alphabetically for deterministic output.
Conversion explained
1. Tokenize lines
YAML is line-oriented. We split the input into lines, strip comments, and skip blank lines. Each remaining line is a key-value pair, a sequence item, or a nested block start.
2. Track indentation
YAML nesting is encoded by leading whitespace. The parser tracks the current indent stack to know when to start a new nested object or array.
3. Emit JSON
The parsed value is serialized with JSON.stringify using your chosen indentation.
YAML to JSON Converter — frequently asked questions
What YAML features are supported?
Block mappings (key: value), block sequences (- item), nested structures via indentation, single and double quoted strings, flow collections ([a,b] and {k:v}), comments (#), and all JSON primitive types. Multi-document YAML and anchors/aliases are not supported.
Why is YAML parsing hard?
YAML is a complex spec with many edge cases: tabs vs spaces, flow vs block style, anchors, aliases, merge keys, tags, and more. JSONLab implements a pragmatic subset that covers the vast majority of real-world YAML configs.
Can I use this for Kubernetes manifests?
Yes! Kubernetes manifests are typically single-document YAML with mappings, sequences, and scalars — exactly what this parser handles.
Is the conversion reversible?
For YAML that maps cleanly to JSON, yes — round-tripping YAML to JSON to YAML produces equivalent data. Comments and formatting may be lost, but the values are preserved.
You might also like
JSON to YAML
Convert JSON to YAML format
JSON to CSV
Convert JSON array to CSV spreadsheet
JSON to XML
Convert JSON to XML format
JSON Validator
Validate JSON syntax with detailed error messages
JSON Formatter
Format and beautify JSON with custom indentation
JSON Beautifier
Pretty-print JSON with syntax highlighting