JSON to YAML Converter
Convert JSON to YAML or YAML to formatted JSON locally in your browser.
Convert JSON and YAML
Choose a direction, paste one document, and convert it locally in your browser.
Supports one YAML 1.2 document using the core schema. Complex mapping keys, custom tags, recursive aliases, non-finite numbers, and unsafe integers are rejected for JSON compatibility.
Your document is processed locally in your browser and is not sent to a server.
Overview
What is a JSON YAML converter?
A JSON YAML converter translates data between JSON and YAML representations. JSON is deliberately compact and strict, while YAML adds a human-oriented syntax used in configuration files, deployment manifests, and documentation.
This page provides both directions in one tool. It converts parsed data rather than merely replacing punctuation, so malformed input and values that cannot be represented safely are reported instead of producing misleading output.
JSON to YAML
How to convert JSON to YAML
- Choose JSON to YAML.
- Paste one valid JSON value into the input editor.
- Select two-space or four-space output indentation.
- Select Convert to YAML or press Ctrl + Enter.
- Review and copy the generated YAML.
YAML to JSON
How to convert YAML to JSON
- Choose YAML to JSON.
- Paste one YAML 1.2 core-schema document.
- Select Convert to JSON.
- Review the formatted JSON and any compatibility warning.
- Use Use output as input to test the reverse direction.
Example
JSON and YAML example
JSON
{
"service": "api",
"enabled": true,
"ports": [80, 443]
}YAML
service: api
enabled: true
ports:
- 80
- 443Data model
JSON and YAML compatibility
YAML 1.2 treats JSON as a compatible subset, but YAML can express more than JSON. JSON object keys are strings and JSON values are limited to objects, arrays, strings, finite numbers, booleans, and null. YAML may additionally contain anchors, aliases, tags, complex mapping keys, multiple documents, comments, and presentation styles.
This converter accepts one YAML document and deliberately rejects values that do not map safely to the JSON data model. That boundary is more reliable than silently coercing or discarding unsupported data.
Round-trip limits
Why conversion is not always lossless
JSON does not store YAML comments, anchors, alias identity, tags, quote style, block style, or original whitespace. Converting YAML to JSON and back can preserve shared data values but not those YAML presentation and graph features. Object property order should not be used as application meaning.
Exact integers outside JavaScript’s safe range should be quoted as strings. This tool rejects unsafe numeric literals rather than returning a rounded value.
Safety
Parser scope and safety limits
- One million UTF-16 code units per input and two million per output.
- 50,000 converted values and a maximum supported nesting depth of 100.
- YAML aliases are limited to prevent excessive expansion.
- Recursive aliases, custom tags, complex mapping keys, and non-finite numbers are rejected.
- Input and output are rendered as plain textarea values and are never executed as HTML.
Workflows
Common JSON and YAML conversion use cases
- Translate an API example into a readable configuration snippet.
- Inspect a YAML configuration as strict JSON data.
- Move simple values between deployment manifests, fixtures, and documentation.
- Identify YAML constructs that cannot safely enter a JSON-only pipeline.
FAQ
Frequently asked questions
Can YAML be converted to JSON?
Yes, when the YAML document uses values that JSON can represent. This tool accepts one YAML 1.2 core-schema document and rejects complex keys, recursive aliases, custom value types, non-finite numbers, and unsafe integers that do not map safely to JSON.
Is JSON valid YAML?
YAML 1.2 was designed so JSON documents are valid YAML. Even so, YAML supports additional presentation features and data structures that JSON does not preserve.
Is JSON to YAML to JSON always lossless?
No. Data values that both formats share can round-trip, but YAML comments, anchors, aliases, scalar style, tags, and formatting are not represented in JSON and therefore cannot be preserved through JSON.
Does this converter support multiple YAML documents?
No. The converter accepts one YAML document at a time. A YAML stream containing document separators and multiple documents is rejected rather than silently dropping data.
How are YAML dates handled?
The converter uses the YAML 1.2 core schema, which does not automatically turn ordinary date-like text into JavaScript Date objects. Quote values explicitly whenever their string type must be unmistakable.
Can YAML aliases create unsafe expansion?
Aliases are supported only within a strict expansion limit. Recursive aliases and documents that exceed the limit are rejected before JSON output is produced.
Why are very large integers rejected?
JavaScript JSON numbers cannot exactly represent every integer. Values outside the safe integer range are rejected; quote exact identifiers or large integers as strings.
Is my JSON or YAML uploaded?
No. Conversion runs locally in your browser, and this tool does not send the document to an external conversion service.