JSON to Kubernetes YAML
This example converts a JSON Kubernetes Pod configuration to YAML format, which is the standard format for Kubernetes manifests.
Switch tool:
Examples:
💡 Paste your JSON and it converts to YAML automatically. Perfect for Kubernetes, Docker Compose, and other DevOps configurations.
Code Examples
Here's how to achieve this in different programming languages:
1// Using js-yaml library (npm install js-yaml)2import yaml from 'js-yaml';34const jsonData = `{"apiVersion": "v1", "kind": "Pod", "metadata": {"name": "my-pod"}, "spec": {"containers": [{"name": "web", "image": "nginx:latest", "ports": [{"containerPort": 80}]}]}}`;5const parsed = JSON.parse(jsonData);6const yamlOutput = yaml.dump(parsed);7console.log(yamlOutput);89// Output:10// apiVersion: v111// kind: Pod12// metadata:13// name: my-pod14// spec:15// containers:16// - name: web17// image: nginx:latest18// ports:19// - containerPort: 80
More JSON Examples
JSON to Docker Compose
Convert JSON service configuration to Docker Compose YAML format.
Simple JSON to YAML
Basic example of converting a JSON object to YAML.
JSON to GitHub Actions
Convert JSON workflow definition to GitHub Actions YAML format.
Nested JSON to YAML
Convert deeply nested JSON configuration to YAML.