JSON ↔ YAML Converter
Convert JSON to YAML or YAML to JSON in both directions. Preserves types, comments, and nesting. Browser-only.
About JSON ↔ YAML Converter
JSON and YAML are both data-interchange formats with similar capabilities, but very different ergonomics. JSON is strict and machine-friendly; YAML is forgiving and reads more naturally for configuration files. This converter translates between the two using a real YAML parser (js-yaml), preserving scalar types (numbers, booleans, null), nested structures, and Unicode strings.
When to use it
- Converting a JSON API response into a readable YAML config
- Translating a Kubernetes/Docker Compose YAML into JSON for tooling that needs it
- Migrating between projects that prefer different config formats
- Comparing two configs that were authored in different formats
- Bringing GitHub Actions or CircleCI YAML into a JSON-only environment
How it works
JSON input is parsed with JSON.parse and re-emitted via js-yaml's safe dumper. YAML input is parsed with js-yaml's safe loader (which only understands the standard YAML 1.2 core schema — no arbitrary code execution) and re-emitted via JSON.stringify with 2-space indent. Both directions round-trip values such as integers, floats, booleans, null, strings, arrays, and maps. YAML-specific features that have no JSON equivalent (anchors, tags) are expanded to their referenced values during conversion.
Examples
{"name":"Ada","skills":["math","logic"],"active":true}name: Ada skills: - math - logic active: true
version: "3"
services:
web:
image: nginx
ports:
- "80:80"{
"version": "3",
"services": {
"web": {
"image": "nginx",
"ports": [
"80:80"
]
}
}
}Frequently asked questions
- Which YAML spec does this support?
- YAML 1.2 core schema via the js-yaml library. This is the same parser used by countless Node.js tools and matches what GitHub Actions, Kubernetes, and most modern YAML consumers expect.
- Can YAML comments survive the round-trip?
- No. YAML comments are not part of the parsed value, so they are lost when converting YAML → JSON and cannot be re-introduced when converting JSON → YAML. If preserving comments matters, edit the YAML file directly.
- What happens to YAML anchors and references?
- Anchors (&id) and aliases (*id) are expanded inline during parsing. The resulting JSON contains the dereferenced value at each use site — meaning the data is duplicated, not shared.
- Are dates and times preserved?
- YAML's ISO-8601 date strings are parsed as JavaScript Date objects by js-yaml and then serialized back to ISO strings when emitted as JSON. Round-tripping preserves the value but converts the type to a string.
- Is the YAML loader safe?
- Yes. js-yaml's safe load mode only resolves the standard YAML core schema — no custom tags, no JavaScript object constructors, no remote includes. Untrusted YAML can be parsed without risk of code execution.