YAML and JSON Converter
Convert YAML to JSON and back, with 2 or 4 space indentation, comments and nested structures supported.
How to Use
- Pick a direction and paste
YAML to JSON checks how a configuration parses; JSON to YAML turns an API response into a config file.
- Set the indentation
Match your project: 2 spaces is common in the Python ecosystem, 4 in JavaScript projects and Kubernetes manifests.
- Read the stats
The key count and line count confirm nothing was dropped; errors name the offending line.
FAQ
Does the key order change when converting to JSON?
No. The parser preserves the order keys appear in the file and the JSON output keeps it, so diffing a configuration file does not produce pointless reordering noise.
Why are some strings quoted?
Because unquoted they could be read as a different type. The string 123 needs quotes to stay a string, since without them YAML reads a number, and values containing a colon, a hash or leading and trailing spaces need quoting too. These are YAML's type inference rules, and quoting proactively keeps the round trip lossless.
Which YAML features are not supported?
Anchors and aliases (& and *), block scalars (| and >), explicit complex keys (the ? form) and multi-line flow collections are not implemented, because they rarely appear in configuration and supporting them would complicate the parser a lot. When something unsupported shows up it tells you the line and the offending fragment instead of silently dropping it.
YAML or JSON?
YAML for configuration: readable, commentable, clear hierarchy. JSON for API payloads: every language parses it and there are no indentation or type-inference traps. If a config is read by a program and also maintained by people, YAML wins; for machine-to-machine data, JSON is the calmer choice.