JSON to Docker Compose
This example converts a Docker Compose configuration from JSON to the more commonly used YAML format.
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 = `{"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);89// Output:10// version: "3.8"11// services:12// web:13// image: nginx14// ports:15// - "80:80"16// db:17// image: postgres18// environment:19// POSTGRES_PASSWORD: secret
More JSON Examples
JSON to Kubernetes YAML
Convert JSON deployment configuration to Kubernetes 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.