🛠️DevTools

Kubernetes YAML to JSON

This example converts a Kubernetes Pod YAML manifest to JSON format for use with kubectl or APIs.

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

💡 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';
3
4const yamlData = `apiVersion: v1
5kind: Pod
6metadata:
7 name: my-pod
8spec:
9 containers:
10 - name: web
11 image: nginx:latest`;
12const parsed = yaml.load(yamlData);
13const jsonOutput = JSON.stringify(parsed, null, 2);
14console.log(jsonOutput);
15
16// Output:
17// {
18// "apiVersion": "v1",
19// "kind": "Pod",
20// "metadata": {
21// "name": "my-pod"...

More YAML Examples

Related YAML Tools

📚 Learn More