🛠️DevTools

JSON to Docker Compose

This example converts a Docker Compose configuration from JSON to the more commonly used YAML format.

Switch tool:
Examples:
YAML output will appear here...

💡 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';
3
4const jsonData = `{"version": "3.8", "services": {"web": {"image": "nginx", "ports": ["80:80"]}, "db": {"image": "postgres", "environment": {"POSTGRES_PASSWORD": "secret"}}}}`;
5const parsed = JSON.parse(jsonData);
6const yamlOutput = yaml.dump(parsed);
7console.log(yamlOutput);
8
9// Output:
10// version: "3.8"
11// services:
12// web:
13// image: nginx
14// ports:
15// - "80:80"
16// db:
17// image: postgres
18// environment:
19// POSTGRES_PASSWORD: secret

More JSON Examples

Related JSON Tools

📚 Learn More