100% local

JSON to YAML Converter

data_object JSON Input
task_alt YAML Output

JSON to YAML Converter

Convert JSON to YAML for Kubernetes manifests, CI pipelines, and Compose files. Strings that a YAML reader might misinterpret are quoted automatically.

YAML is a superset of JSON, so every JSON document has a YAML equivalent and the conversion never loses data. What it does change is how the values are written, and YAML has considerably more ways to write the same value than JSON does. Most of the interesting behaviour in this converter is about picking a form that reads back as the value you started with.

The output uses two space indentation, a 120 character line width, and no reference aliases, which matches the conventions of Kubernetes manifests and the major CI configuration formats. Arrays are written as block sequences with a dash per element rather than inline, because that is what people expect to read and edit in a config file.

Quoting, and why yes is not a boolean here

The best known YAML hazard is the Norway problem. YAML 1.1 defines a generous set of boolean spellings, including yes, no, on, off, y, and n, so a country code list containing NO can silently become a list containing false. YAML 1.2 narrowed booleans to true and false only, but plenty of readers still implement 1.1 behaviour.

This converter emits quoted strings for any value that a looser reader could coerce. The JSON string "yes" comes out as the quoted YAML scalar with quotes intact, and so does "no". The same protection applies to version numbers: the string "1.10" is quoted, because unquoted it would read as the number 1.1 and lose the trailing zero. If you see quotes in the output where you did not expect them, that is the converter defending the value, not adding noise.

Long strings are folded rather than wrapped mid token. Past the 120 character line width, a scalar is written as a folded block using the greater than and minus indicators, which tells a YAML reader to join the wrapped lines back into a single line and strip the trailing newline. It looks unfamiliar but round trips exactly. Anchors and aliases are disabled, so a value repeated in two places is written out twice rather than referenced, which keeps the output readable at the cost of some bytes.

How values are written in the output

Each row is a real JSON value and the exact YAML this tool emits for it.

JSON valueYAML outputNotes
"no"region: 'no'Quoted, so a YAML 1.1 reader cannot turn it into false. This is the Norway problem defence.
"yes"enabled: 'yes'Quoted for the same reason. Unquoted yes reads as true in YAML 1.1.
"1.10"version: '1.10'Quoted to protect the trailing zero. Unquoted it would parse as the number 1.1.
"Seoul"city: SeoulAn ordinary word needs no quoting and gets none.
trueactive: trueA real boolean is written bare, which is how it should read back.
[80, 443]ports: - 80 - 443Written as a block sequence, one dash per element, not inline.
[]extras: []An empty array stays in flow style, because there is no element to put on a line.
"xxx... (140 chars)"longtext: >- xxx...Folded block scalar past 120 characters. Reads back as one line with no trailing newline.

Converting a config object

Note which strings end up quoted and which do not.

Input
{
  "region": "no",
  "enabled": "yes",
  "version": "1.10",
  "city": "Seoul",
  "active": true,
  "ports": [80, 443],
  "extras": []
}
Output
region: 'no'
enabled: 'yes'
version: '1.10'
city: Seoul
active: true
ports:
  - 80
  - 443
extras: []

Only the values that a YAML reader could misread are quoted. Seoul is written bare because no reader would turn it into anything else.

Common Pitfalls

Do not strip the quotes the converter added

Quotes around values like no, yes, off, or 1.10 are load bearing. Removing them to tidy up the file can change a string into a boolean or a version into a truncated number, and the failure often shows up far from the edit. If a quoted scalar looks ugly, leave it ugly.

region: 'no'   # string "no"
region: no     # boolean false in YAML 1.1

YAML is a superset, so converting back is not automatic

Every JSON document is valid YAML, but not every YAML document is valid JSON. Anchors, multiple documents in one file, non string keys, and comments have no JSON equivalent. This tool converts one direction only, and a YAML file that uses those features cannot be represented as JSON without restructuring.

Comments cannot survive a round trip through JSON

If you took a commented YAML config, converted it to JSON somewhere, and are now converting back, the comments are already gone. JSON has no comment syntax, so they were dropped at the first conversion. Keep the original YAML if the comments matter.

How to Use

  1. Paste your JSON: Paste the JSON config or manifest you want to move into a YAML based tool.
  2. Click Convert: The tool converts your JSON to clean, properly indented YAML.
  3. Copy the YAML: Copy the YAML output and use it in your configuration files, Kubernetes manifests, or CI/CD pipelines.

Key Features

  • Clean, human-readable YAML output with proper indentation
  • Handles nested objects, arrays, and all JSON data types
  • No reference aliases: each value is written inline for clarity
  • 120-character line width for optimal readability

Use Cases

  • Converting JSON API configs to YAML for Kubernetes deployments
  • Transforming JSON settings into YAML for CI/CD pipeline configuration (GitHub Actions, GitLab CI)
  • Creating YAML-based configuration files from JSON templates

Frequently Asked Questions

Is the YAML output valid?

Yes. The converter produces valid YAML that can be used directly in configuration files, Kubernetes manifests, and other YAML-compatible tools.

Does YAML support all JSON data types?

Yes. YAML is a superset of JSON, so all JSON data types (strings, numbers, booleans, null, arrays, objects) are fully supported.

Are comments preserved?

JSON has no comment syntax, so a JSON input never carries comments to preserve. If your data originally came from a commented YAML file, those comments were lost when it was converted to JSON, before reaching this tool.

Can I convert YAML back to JSON?

Not with this tool directly. PureJSON focuses on JSON-to-YAML conversion. However, since YAML is a superset of JSON, you can use a YAML parser to convert back.

How does it handle values like no and yes?

Yes, and more carefully than you might expect. Values that a YAML 1.1 reader could coerce into a boolean or a number are quoted automatically. The strings "yes", "no", and "1.10" all come out quoted so they read back as strings.

Why are some strings quoted and others not?

Quoting is applied only where it is needed to preserve the value. A plain word like Seoul cannot be misread, so it is written bare. A word like no could be read as a boolean by a YAML 1.1 parser, so it is quoted. The rule is minimal quoting, not no quoting.

What is the greater than sign in my output?

It is a folded block scalar, used for strings longer than the 120 character line width. The following lines are joined back into one line when read, and the minus suffix strips the trailing newline. The value round trips exactly.