JSON ↔ YAML Converter

Convert JSON to YAML or YAML to JSON instantly in your browser.

JSON INPUT
0 chars
YAML OUTPUT

When a JSON ↔ YAML converter is the right tool

The same configuration often exists as JSON in an API and as YAML in a Helm values file or a workflow. A converter is for that moment. You paste one format, choose the direction, and get the other, with the output updating as you type. JSON → YAML is the default; you can switch to YAML → JSON or Swap a successful result to go back.

The conversion is a parse-and-dump, not a comment-preserving rewrite. If you only need to tidy one format, use the JSON Formatter or the YAML Formatter instead.

Use cases

Turning an API payload into a YAML values file

Paste the JSON, leave the direction on JSON → YAML, and copy the 2-space dump into a values file or a gist. This is a starting point; you will still need to add comments yourself if the team expects them.

Turning a YAML manifest into JSON for a tool that only accepts JSON

Switch to YAML → JSON, paste a single document, and copy the pretty-printed JSON. If the paste contains more than one document separated by ---, split it first.

Checking a round trip

After a successful conversion, Swap puts the output in the input and reverses the direction. Use that to see whether dates or numbers were rewritten, not as a proof that the two files are byte-for-byte equivalent.

How conversion works

JSON → YAML calls JSON.parse, then yaml.dump with 2-space indent and no line wrapping. YAML → JSON calls yaml.load, then JSON.stringify with 2-space indent. Errors from those functions are shown in the output pane. There is no indent control and no sample button. Empty input leaves the output empty.

Switching the direction buttons leaves your current input in place, so the page will try to parse it as the newly selected format. Swap is disabled until there is successful output.

Example — a small object converted to YAML
{
  "name": "my-app",
  "version": "1.0.0",
  "debug": true
}

name: my-app
version: 1.0.0
debug: true

Keys and values are the same. A string such as 1.0.0 is left unquoted by this dump; booleans and nested objects follow js-yaml’s usual style.

Example — a YAML date may become a JSON timestamp
release: 2020-01-01

{
  "release": "2020-01-01T00:00:00.000Z"
}

A bare date in YAML can be loaded as a timestamp and written in JSON with a time and a Z suffix. If you convert that JSON back to YAML, you will not get the original short date back.

What this tool does not do

It does not preserve comments, format several YAML documents in one stream, or offer a 4-space indent. It does not validate a Kubernetes or JSON Schema. Nothing is sent to a server. To compare two JSON or YAML files after you convert, use JSON Diff or YAML Diff.

How to use JSON ↔ YAML Converter

  1. Choose JSON → YAML or YAML → JSON.
  2. Paste the source into the input pane. The output updates as you type.
  3. Copy the result when it looks right, or Swap to convert the output back the other way.
  4. Use Clear to empty the input.

Frequently asked questions

How does JSON → YAML work?

The input is parsed with JSON.parse, then written with js-yaml’s dump function at 2-space indent and with line wrapping turned off. Comments cannot appear in the JSON input, and the YAML output is a fresh serialization, not a whitespace-only tidy of something you already had.

How does YAML → JSON work?

The input is parsed with js-yaml’s load function, which accepts a single YAML document, then written with JSON.stringify at 2-space indent. Multi-document streams that use --- will fail with an error that more than one document was found.

Why did my YAML comments disappear?

Comments are not part of the data model used here. YAML → JSON keeps only the loaded values. JSON → YAML then dumps those values, so comments never come back. If you need to keep comments, do not run the file through this converter.

Will dates and numbers look the same after a round trip?

Not always. A YAML value such as 2020-01-01 may be parsed as a timestamp and appear in JSON as 2020-01-01T00:00:00.000Z. A number such as 1.0 may become 1. These are serialization choices, not necessarily a change in meaning, but they can surprise you in a diff.

What does Swap do?

If there is successful output, Swap puts that output into the input and flips the direction, so you can convert back the other way. The direction buttons themselves do not clear the input; if you switch direction while the old text is still in the box, the page will try to parse it as the new format.

Is my data sent to a server?

No. Conversion runs in your browser as you type. Closing the tab discards what you pasted. Do not paste documents that contain secrets if you would not be comfortable with them sitting in memory on this device.

Is there a file size limit?

There is no server-imposed limit, because nothing is uploaded. A few thousand lines is comfortable. A very large document can make the tab feel slow; in that case, convert a smaller excerpt or use a local tool.

Related tools and guides

References

  • RFC 8259 is the JSON format used on the JSON side. Comments and trailing commas will fail JSON.parse.
  • YAML 1.2.2 defines YAML documents. This page loads and dumps through js-yaml, so comments are not preserved and some scalars may be rewritten.