Last updated

Common YAML to JSON Use Cases

Examples

Example 1: Basic YAML to JSON

A simple YAML configuration file converts to an equivalent JSON object.

Input YAML:
name: my-app
version: "1.0.0"
debug: false
port: 8080
database:
  host: localhost
  port: 5432
  name: mydb

Output JSON:
{
  "name": "my-app",
  "version": "1.0.0",
  "debug": false,
  "port": 8080,
  "database": {
    "host": "localhost",
    "port": 5432,
    "name": "mydb"
  }
}

Example 2: YAML Arrays to JSON Arrays

YAML sequences (arrays) convert directly to JSON arrays.

Input YAML:
servers:
  - host: web-01.example.com
    port: 80
    role: primary
  - host: web-02.example.com
    port: 80
    role: secondary
  - host: web-03.example.com
    port: 80
    role: secondary

allowed_origins:
  - https://example.com
  - https://app.example.com
  - https://admin.example.com

Output JSON:
{
  "servers": [
    { "host": "web-01.example.com", "port": 80, "role": "primary"   },
    { "host": "web-02.example.com", "port": 80, "role": "secondary" },
    { "host": "web-03.example.com", "port": 80, "role": "secondary" }
  ],
  "allowed_origins": [
    "https://example.com",
    "https://app.example.com",
    "https://admin.example.com"
  ]
}

Example 3: Kubernetes Manifest to JSON

Kubernetes manifests are written in YAML but kubectl and many tools also accept JSON. Converting enables using jq for processing.

Input YAML (Kubernetes Deployment):
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app
  namespace: production
  labels:
    app: my-app
    version: "1.0.0"
spec:
  replicas: 3
  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
        - name: my-app
          image: my-app:1.0.0
          ports:
            - containerPort: 8080

Output JSON:
{
  "apiVersion": "apps/v1",
  "kind": "Deployment",
  "metadata": {
    "name": "my-app",
    "namespace": "production",
    "labels": { "app": "my-app", "version": "1.0.0" }
  },
  "spec": {
    "replicas": 3,
    "selector": { "matchLabels": { "app": "my-app" } },
    "template": {
      "metadata": { "labels": { "app": "my-app" } },
      "spec": {
        "containers": [
          {
            "name": "my-app",
            "image": "my-app:1.0.0",
            "ports": [{ "containerPort": 8080 }]
          }
        ]
      }
    }
  }
}

Frequently Asked Questions

Yes, our Yaml To Json is completely free with no registration required. Use it unlimited times without any restrictions.

Yes, all processing happens locally in your browser. Your data never leaves your device and is not stored on our servers.

No installation needed. The tool works directly in your web browser on any device.

The tool supports all standard formats. Simply paste your input and the conversion happens instantly.

Yes, you can process multiple conversions by using the tool repeatedly. Each conversion is instant.