Development

JSON to YAML Converter

Convert JSON to YAML and YAML to JSON as you type, with indentation and key-sorting options, errors that point to the line and column, and copy or download.

JSON to YAML Converter
Edit either side. The other side updates as you type.

Valid JSON

YAML comments are dropped, since JSON has no comments. Anchors and aliases are expanded. Converted with the yaml library (YAML 1.2) in your browser.

About this tool

The JSON to YAML Converter turns JSON into clean YAML and YAML back into JSON, live in both directions. Paste a JSON document on one side and read the YAML on the other, or edit a Kubernetes manifest, GitHub Actions workflow or Docker Compose file in YAML and get the equivalent JSON. Choose 2 or 4-space YAML indentation, and 2 spaces, 4 spaces, tabs or minified output for JSON, and sort keys alphabetically to make two files easy to compare. When the input is not valid, the error says what is wrong and gives the line and column, such as a trailing comma or single quotes in JSON, or a duplicate key or bad indentation in YAML. Multi-document YAML becomes a JSON array, anchors and aliases are expanded, and warnings flag anything JSON cannot hold, like very large integers or .inf. Load a sample to try it, then copy or download either side. Conversion uses the open-source yaml library and runs in your browser.

How to use the JSON to YAML Converter

  1. Paste JSON in the left box or YAML in the right box. The other side updates as you type.
  2. Choose the YAML and JSON indentation, and turn on Sort keys if you want keys in alphabetical order.
  3. If the input is invalid, read the error under the box for the line and column to fix.
  4. Click Sample to load an example of either format.
  5. Copy or download the JSON or YAML.

Use it from your code

The JSON to YAML Converter is also a REST API endpoint. Create a free API key and call it from your own scripts and apps.

curl -X POST https://opentools.ca/api/v1/tools/json-yaml-converter \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "direction": "json-to-yaml",
    "text": "{\"name\":\"app\",\"ports\":[80,443],\"debug\":false}"
  }'

Give us your feedback

Help us improve JSON to YAML Converter!

Frequently asked questions

Are comments kept?

No. JSON has no comments, so YAML comments are dropped when converting to JSON, and they cannot come back when converting the other way.

What happens to multiple YAML documents separated by ---?

They become a JSON array with one item per document, and a note says so. Converting that JSON back gives a single YAML document containing a list.

Which YAML version does it follow?

YAML 1.2, the current version. Words like yes, no, on and off stay strings rather than turning into true and false as they did in YAML 1.1, and duplicate keys are reported as errors.

Why does it warn about large numbers?

JavaScript numbers are exact only up to 9,007,199,254,740,991. Larger integers, such as some database IDs, are rounded during conversion. Quote them as strings to keep every digit.

Is my data uploaded?

No. Parsing and conversion happen in your browser, so configuration files and secrets stay on your device.

JSON to YAML Converter screenshot