JSON ↔ YAML Converter

Convert JSON to YAML or YAML to JSON instantly.

Input JSON
1
YAML Output

Paste JSON on the left to convert to YAML

2sp · UTF-8

Example Conversion

JSON:

json
{
  "apiVersion": "v1",
  "kind": "Service",
  "metadata": { "name": "my-service" },
  "spec": {
    "ports": [{ "port": 80, "targetPort": 8080 }]
  }
}

YAML:

yaml
apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  ports:
    - port: 80
      targetPort: 8080

JSON vs YAML Syntax

JSONYAML
{ "key": "value" }key: value
["a", "b", "c"]- a - b - c
"string"string (quotes optional)
true / falsetrue / false (or yes/no)
nullnull or ~
// not supported# this is a comment

Common Use Cases

  • Kubernetes manifestsConvert JSON API responses to YAML configs for kubectl apply
  • Docker ComposeCreate docker-compose.yml from JSON templates
  • CI/CD pipelinesGitHub Actions, GitLab CI and CircleCI all use YAML configs
  • Ansible playbooksConvert JSON data to YAML format for Ansible automation
  • Helm chartsGenerate values.yaml files from JSON configuration

Special Characters in YAML

The converter automatically quotes strings that could be misinterpreted by YAML parsers:

Strings starting with numbers:"123abc"
Strings containing colons:"host:port"
Boolean-like strings:"yes", "no", "true"
Strings with special chars:"#", "&", "*"

Programmatic Conversion

JavaScript (Node.js):

js
const yaml = require('js-yaml');
const jsonData = { name: 'example', count: 42 };
const yamlString = yaml.dump(jsonData);
console.log(yamlString);

Python:

python
import json, yaml
with open('data.json') as f:
    data = json.load(f)
with open('data.yaml', 'w') as f:
    yaml.dump(data, f, default_flow_style=False)

Frequently Asked Questions

Both store structured data. YAML uses indentation instead of brackets and is more human-readable. JSON is more universally supported in APIs and programming languages.

Yes. Use the YAML → JSON toggle in the page header to switch direction. Paste your YAML in the input and get JSON output.

No. JSON does not support comments. When converting YAML to JSON, all # comments are stripped from the output.

YAML uses indentation to define structure instead of brackets. This makes it more readable for humans but requires consistent spacing — always use spaces, never tabs.

Related Tools