OnSumo Tools

JSON to YAML Converter

This tool converts JSON to YAML and YAML to JSON in one click. Paste your JSON or YAML into the input, select the target format, and the tool returns the converted output with correct indentation and syntax. Conversion happens entirely in your browser. Your data never leaves your device, which matters when you are working with API keys, database credentials, Kubernetes secrets, or any configuration that should not pass through an external server.

Direction

YAML anchors are resolved when converting to JSON. JSON does not support comments or anchors.

YAML output

Input: 0 chars

How this tool works

The JSON-YAML converter bidirectionally transforms JSON and YAML while preserving the semantic structure of the data. JSON-to-YAML conversion replaces braces and brackets with indentation and dashes, strips explicit quotes from string keys where not required, and uses bare null or the tilde (~) for null values per the YAML 1.2 spec. YAML-to-JSON conversion serializes scalar types with careful handling of YAML's boolean ambiguity: unquoted yes, no, on, and off are booleans in YAML 1.1 (used by PyYAML and Ruby's default YAML) but plain strings in YAML 1.2. The tool defaults to YAML 1.2 behavior with a toggle to YAML 1.1 coercion for compatibility with legacy parsers. YAML anchors and aliases are fully resolved to their referenced values before conversion, since JSON has no equivalent reference mechanism. Key assumption: the tool processes single-document YAML; multi-document streams (separated by ---) convert each document independently to a JSON value and wrap the results in a JSON array. Edge case: YAML allows inline comments but JSON does not. Comments are stripped silently during YAML-to-JSON conversion and cannot be round-tripped back to YAML. If your YAML file relies on comments for documentation, maintain the YAML source separately alongside the JSON export.

Worked example

{"name": "John", "age": 30} becomes YAML with name and age keys. A YAML literal block (|) becomes a JSON string with newline characters. {"key": null} round-trips as null, not the string "null".

Related tools

Frequently asked questions

  • Is YAML a superset of JSON?

    Yes, in most cases. Valid JSON is also valid YAML 1.2. This means you can paste a JSON string directly into a YAML parser and it will parse correctly. However, JSON's handling of numbers with leading zeros and some edge cases differ between implementations, so the tool uses explicit conversion rather than relying on YAML's JSON compatibility mode.

  • What happens to YAML comments when converting to JSON?

    They are discarded. JSON has no comment syntax. If you convert YAML-with-comments to JSON and back to YAML, the comments will be gone. If you need to preserve comments, keep the canonical version as YAML and generate JSON from it programmatically, treating JSON as the derived format.

  • What are YAML anchors and aliases, and how are they handled?

    Anchors (&anchor-name) and aliases (*anchor-name) are a YAML feature for reusing values. An alias in YAML is a reference to a previously defined anchor. When converting to JSON, the tool resolves aliases and inlines the referenced value at each usage site. JSON has no reference mechanism, so each value must be spelled out.

  • Does the tool support YAML 1.1 vs YAML 1.2 differences?

    The tool uses a YAML 1.2 parser, which is the current standard. YAML 1.1 had quirks like interpreting yes/no/on/off as booleans. YAML 1.2 only treats true and false as booleans. If you have YAML 1.1 content that uses yes or no as booleans, the tool may treat them as strings.

  • Why does my number `007` become `7` in JSON?

    JSON numbers do not allow leading zeros (they would be interpreted as octal in some parsers). When YAML containing 007 is converted to JSON, the leading zeros are stripped to produce a valid JSON number. If 007 is intended as a string, quote it in the YAML source: \\\\\\\"007\\\\\\\".

  • Can I use this for converting package.json to YAML?

    Yes. Any JSON can be converted to YAML. However, package.json is expected to be JSON by npm and all Node.js tooling. Converting it to YAML would require renaming it and adding a tool that can read YAML package files. The conversion is technically possible but not recommended without a toolchain that supports YAML package configuration.