JSON tool
JSON ↔ YAML
Convert JSON to YAML or YAML to JSON locally in your browser.
Result
Your result will appear here.
How to use JSON ↔ YAML
- Choose JSON → YAML or YAML → JSON.
- Paste a document and select Convert.
Example
{"service":"web","replicas":2}Common use cases
- Turning a YAML configuration file such as a Docker Compose or CI file into JSON so that a script or API client can read it.
- Converting a JSON settings object into YAML before pasting it into a configuration file that expects YAML.
- Checking how a YAML value will be read as JSON, for example to see whether a value became a string or a number.
Input and output examples
| Input | Output | Notes |
|---|---|---|
{"service":"web","replicas":2} | service: web
replicas: 2 | JSON → YAML. Key order is kept. |
on: yes
flag: no | {
"on": "yes",
"flag": "no"
} | YAML → JSON. yes and no stay strings in YAML 1.2. |
Common mistakes to avoid
- Indentation is structure in YAML. One misaligned space can move a key under a different parent, so check the converted JSON against what you expected.
- A round trip loses information. Converting YAML to JSON and back removes comments and anchors, so keep the original file as the source of truth.
- Plain scalars are interpreted, not copied. Values such as 1.10 or 0755 change meaning, so quote any value whose exact text matters.
Technical details
YAML parsing and writing use the yaml library, which implements YAML 1.2. In YAML 1.2 the words yes, no, on, and off are plain strings, not booleans. JSON input follows RFC 8259. Comments and original formatting are not kept, and anchors and aliases are expanded into plain values in the output.
Frequently asked questions
Are YAML anchors preserved?
No. The converter works with parsed values, so an anchor and its aliases become repeated plain values in the JSON output. Comments and formatting details are not preserved.
Why did yes and no stay as text?
YAML 1.2, the version this tool uses, reads yes, no, on, and off as strings. Older YAML 1.1 parsers, including the default loader in PyYAML, read them as booleans, so the same file can mean different things in different tools.
Why did 0755 become 755?
YAML 1.2 reads a leading-zero number as decimal. Octal numbers need the 0o prefix, so write 0o755 when you mean octal.
Why was 1.10 converted to 1.1?
YAML reads 1.10 as a floating-point number, and the trailing zero is not part of its value. Quote the value, such as "1.10", when the exact text matters.
Why are some numbers quoted in the YAML output?
A string that looks like a number, such as "10", is quoted so it is not read back as a number. A string such as yes is written without quotes, because YAML 1.2 does not treat it as a boolean.
Is my YAML or JSON uploaded?
No. Conversion runs in your browser, and the tool code does not send the text to a server.