Stavekit

JSON to YAML converter

Turn a JSON object or array into tidy YAML you can read and edit. Invalid JSON is flagged with a line and column.

Advertisement
Advertisement

How to convert JSON to YAML

Paste a JSON object or array into the input box — or load the example — and choose Convert. The tool parses the JSON on your device and writes YAML with two-space indentation. Copy the result, or download it as a .yaml file. You do not create an account, and the text is not uploaded to Stavekit to perform the conversion.

This direction is useful when you have been given an API response, a package.json fragment, or a Terraform/CI example in JSON and you would rather edit it as YAML. YAML is usually shorter to look at: braces and commas fall away, and lists become dashed lines. The content should be equivalent, not a creative rewrite.

What valid JSON looks like here

The input must be standard JSON: double-quoted keys and strings, no trailing commas, no comments, and no single quotes. Those rules surprise people who are used to JavaScript objects or YAML. If you paste a trailing comma after the last property, the tool reports an error and, when it can, the line and column of the failure. Fix the JSON first; the converter will not try to “help” by deleting a comma you might have meant to notice.

The root value can be an object, an array, or even a single string or number. Most configuration use-cases start with an object. After conversion, check that booleans and nulls look the way you expect (true, false, and null in YAML), and that long strings are still readable.

Formatting choices

The YAML is dumped with a conservative width and without Python-style references that would replace repeated objects with anchors. That keeps the file obvious, even if it is slightly longer when the same object appears twice. Keys stay in the order they appeared in the JSON, which matches how most people edit a file. If you need a strictly canonical document for a signature or a diff, run your own formatter in your project; this page is a practical editor’s helper, not a cryptography tool.

When conversion is the wrong first step

If the JSON is actually a stream of many objects (JSON Lines), convert one object at a time or use a dedicated jq-style tool. If you need comments, add them in the YAML after conversion — JSON has no comments to preserve. If you started from YAML, converted to JSON, and now convert back, small style differences are normal: quoting, line wrapping, or the way null is written may change, even when the data is the same.

Privacy

API tokens, internal hostnames and draft payloads sometimes travel in JSON you are only trying to read. Because parsing happens in the browser, that material stays on the machine in front of you. Still, avoid pasting secrets into any shared computer, and clear the boxes when you are done if someone else might use the device.

Frequently asked questions

Why is my JSON rejected?

Typical causes are a trailing comma, comments, or single-quoted strings. JSON is stricter than JavaScript. The error message includes a line and column when the parser can locate the problem.

Are comments preserved?

JSON does not support comments, so there are none to keep. You can add YAML comments after the conversion.

Does this work offline?

After the page and its scripts have loaded, the conversion does not need a network request. You can even save the page for local use.

Will key order change?

No alphabetical sorting is applied. Keys are written in the order they appeared in the JSON object.

Can I go back to JSON?

Yes. Use the YAML to JSON converter, which also runs locally and reports line-level YAML errors.