Kubernetes YAML to JSON
This example converts a Kubernetes Pod YAML manifest to JSON format for use with kubectl or APIs.
Switch tool:
Examples:
💡 Paste your YAML and it converts to JSON automatically. Perfect for converting Kubernetes and Docker Compose configs.
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 yamlData = `apiVersion: v15kind: Pod6metadata:7 name: my-pod8spec:9 containers:10 - name: web11 image: nginx:latest`;12const parsed = yaml.load(yamlData);13const jsonOutput = JSON.stringify(parsed, null, 2);14console.log(jsonOutput);1516// Output:17// {18// "apiVersion": "v1",19// "kind": "Pod",20// "metadata": {21// "name": "my-pod"...
More YAML Examples
Docker Compose to JSON
Convert Docker Compose YAML configuration to JSON format.
Simple YAML to JSON
Basic example of converting YAML configuration to JSON.
GitHub Actions to JSON
Convert GitHub Actions workflow YAML to JSON for analysis.
Nested YAML to JSON
Convert deeply nested YAML configuration to JSON.