How to convert JSON to YAML or YAML to JSON
- Select the direction that matches your source. Try sample input loads YAML, so use YAML to JSON for that example.
- Paste one document, or select a local JSON, YAML or text file. Choose its file encoding when needed.
- Select two or four spaces, then Convert configuration. Results update when you run the operation.
- Read any error before exporting. Copy result copies the complete output; Download creates a .json or .yaml file.
Switching direction does not silently overwrite your source. To round-trip a result, copy it into the input and select the opposite direction. Keep an original copy if comments or formatting matter.
What this configuration converter does
JSON and YAML represent mappings, lists and scalar values using different syntax. A JSON object uses quoted keys and braces. YAML can use an indented mapping. Converting helps when an API accepts JSON but a configuration editor is easier to read in YAML, or when you want to inspect the values produced by a YAML parser.
This is a representation change, not an application validator. A converted deployment file can still contain an unsupported setting or incorrect value. Use the receiving application’s validation tools before deploying it. For indentation alone, JSON Formatter avoids changing formats.
How types and numeric precision are handled
The YAML parser uses YAML 1.2 core types. Plain true and false become booleans; yes and on remain strings. Dates remain strings under this schema. Quote a numeric-looking identifier such as "00123" when its written form matters. Every mapping key must be a string.
Integer values use arbitrary-precision arithmetic, so 9007199254740993 remains exact. Decimal and exponent values are accepted only when their decimal value survives conversion through the supported number representation. Values that would round or overflow are rejected with a request to quote them. Negative zero and ordinary values such as 1.25 are supported, but exponent notation and trailing decimal zeros may change.
JSON input first passes the existing strict, duplicate-key-rejecting parser. Generated YAML quotes strings and keys to reduce ambiguity in other readers. This converter preserves supported data values, not the original whitespace, numeric spelling or comments.
A configuration example
Input
name: Ada active: true roles: - editor
Output
{
"name": "Ada",
"active": true,
"roles": [
"editor"
]
}The role sequence becomes a JSON array, the name remains a string, and active remains a boolean. Changing true to "true" deliberately changes the type. Open the result in JSON Viewer to explore branches, or compare two outputs with structural JSON comparison.
Common errors and compatibility limits
Use spaces consistently for indentation. Syntax errors include line and column information where the parser provides it. Duplicate keys, multiple documents, YAML 1.1 directives, custom tags, complex or non-string mapping keys, anchors, aliases and merge keys are rejected. Expand references explicitly before converting. Nonfinite values such as .nan and .inf cannot become JSON numbers.
Input is limited to 1 MiB, 50 nesting levels and 20,000 values. Numeric tokens have a 4,096-character bound. The browser worker can be cancelled and stops after eight seconds. These limits also prevent alias expansion from becoming a hidden resource problem; aliases are never expanded by this tool. Comments are discarded because JSON has no comment syntax. A comment-only document has no value and is rejected.
Local conversion and useful next steps
The selected file or pasted text is processed in a browser worker. It is not sent to a conversion server or automatically stored. Reset clears the interface; copies in the clipboard or downloaded files remain under your control. Website pages and scripts still require ordinary hosting requests.
For table-shaped records, use JSON to CSV after checking nested objects and arrays. A YAML document is not necessarily a table, so inspect its structure before flattening it. The converter uses the maintained YAML parser with the restrictions described above.
Frequently asked questions
Why are YAML strings quoted in the output?
Quotes keep strings distinct from booleans, numbers and other scalar types when another parser reads them.
Can I convert a Kubernetes multi-document stream?
Not in one run. Convert each document separately; multi-document input is rejected instead of silently keeping the first document.
Does conversion preserve comments?
No. JSON has no comment syntax. Keep the YAML source if you need its comments or original presentation.