If you are working with Kubernetes manifests or Helm charts, you have likely seen the error: error converting YAML to JSON: did not find expected key.
YAML is incredibly space-sensitive. A single tab character where a space should be, or a 3-space indentation instead of 2, can break an entire production deployment.
Common YAML to JSON Pitfalls
- Tab Characters: YAML strictly forbids tabs. Most IDEs convert them, but copy-pasting from documentation often introduces them.
- Key Collisions: YAML allows more flexible keys than JSON. When converting to a JSON API, some keys might be dropped if they aren't unique strings.
- Indentation Mismatch: Unlike JSON's braces
{}, YAML relies entirely on the 'visual column' to understand parent-child relationships.
How to Validate Safely
Don't guess. Use a validator that runs in your browser to avoid leaking sensitive environment variables or database secrets to a backend server.