YAML to JSON Converter
Paste YAML, get JSON instantly. Live conversion in your browser. K8s manifests, OpenAPI specs, helm values supported. 100% private, no upload.
Options · 2 spaces
What is JSON?
JSON (JavaScript Object Notation) is a lightweight, text-based data interchange format standardized as RFC 8259 and ECMA-404. It supports six data types — strings, numbers, booleans, null, arrays, and objects — with a strict, minimal syntax that virtually every programming language, API, and toolchain can parse natively. While YAML is the preferred format for human-written configuration files (Kubernetes manifests, GitHub Actions, Ansible playbooks, Helm values), JSON is the universal machine-readable format for APIs, automation scripts, and programmatic data processing.
Converting YAML to JSON is therefore one of the most common tasks in DevOps and backend development — you have a YAML config file but need JSON to feed into a REST API, query with jq, or process with JavaScript tooling.
This tool has four important differentiators compared to typical online converters:
**1. Multi-Document YAML Handling.** YAML supports multiple documents in a single stream separated by --- (the document start marker). Many real-world YAML files — including some Kubernetes manifests and Ansible playbooks — contain multiple documents. This tool uses parseAllDocuments from the eemeli/yaml library with { version: '1.2', merge: true } options and returns the first document as JSON, clearly communicating what was taken. If you need all documents, split on --- and convert each individually.
**2. Anchor and Alias Expansion.** YAML anchors (&name) and aliases (*name) allow reuse of data blocks — a powerful YAML feature with no JSON equivalent. This tool fully expands all anchors and aliases (including merge keys: <<: *anchor) so the JSON output contains complete, self-contained data without any references. This is always the correct transformation because JSON has no reference syntax. The expansion is handled safely by the eemeli/yaml library, which includes protection against circular references. Learn how this compares to the reverse direction at JSON to YAML Converter.
**3. Comment Loss — Educational Transparency.** YAML supports # comments, which are frequently used in Kubernetes manifests, Helm values, and Ansible playbooks to document intent. JSON has no comment syntax, so comments are permanently dropped during conversion. This is not a bug — it is a fundamental format difference. This tool makes this explicit so you know what to expect. If you need to preserve annotations, encode them as JSON fields (_comment keys or a dedicated metadata object) before converting, or keep YAML as the authoritative source. See our deep dive on YAML-JSON differences for more on format tradeoffs.
**4. 100% Browser-Based Privacy.** Your YAML data — which often contains Kubernetes secrets, database credentials, Helm values with passwords, and internal service configurations — never leaves your browser. No data is sent to any server. You can verify this in your browser's Network tab. After converting to JSON, you can validate and format the result with our JSON Formatter before using it downstream.
YAML's richness (comments, anchors, multi-document support, block scalars) makes it excellent for human-authored configuration files where readability and documentation matter. JSON's strictness and universality make it the better choice when a machine is the primary consumer. This converter bridges the two worlds: keep your configuration in YAML for human maintainability, convert to JSON when you need machine-readable interchange.
// Convert YAML to JSON in Node.js using the eemeli/yaml library
import { parseAllDocuments } from 'yaml';
const yamlString = `apiVersion: apps/v1
kind: Deployment`;
// parseAllDocuments handles multi-document YAML (--- separator)
// version: '1.2' ensures yes/no are strings, not booleans
// merge: true expands anchor/alias merge keys (<<: *anchor)
const docs = parseAllDocuments(yamlString, { version: '1.2', merge: true });
// Take the first document (skip additional --- blocks)
const json = JSON.stringify(docs[0].toJSON(), null, 2);
console.log(json);
// {
// "apiVersion": "apps/v1",
// "kind": "Deployment"
// } Key Features
Live Conversion
JSON output updates instantly as you type or paste YAML — no Convert button needed. Large inputs (>200KB) automatically switch to manual mode to keep the browser responsive.
Indent 2 or 4 Spaces
Switch between 2-space and 4-space indentation for the JSON output. 2 spaces is standard for most tooling and APIs; 4 spaces matches some style guides and editor defaults.
Multi-Document Support
Handles YAML streams with multiple --- separated documents. The first document is converted to JSON and returned. Useful for Kubernetes multi-resource files and Ansible playbooks.
Anchor and Alias Expansion
Fully expands YAML anchors (&name) and aliases (*name), including merge keys (<<: *anchor). The JSON output contains complete, dereferenced data with no references — correct behavior since JSON has no equivalent.
100% Browser-Based Privacy
All conversion runs locally in your browser using JavaScript. Your YAML data — including secrets, credentials, and production configs — is never sent to any server, never logged, and never stored.
Handles K8s, Compose, Helm, and OpenAPI
Optimized for real-world DevOps use cases: Kubernetes manifests, Docker Compose stacks, Helm chart values, GitHub Actions workflows, OpenAPI specs, and Ansible playbooks — with examples for each.
Examples
Kubernetes Manifest
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
resources:
requests:
memory: 64Mi
cpu: 250m
limits:
memory: 128Mi
cpu: 500m Convert a Kubernetes Deployment manifest from YAML to JSON — useful for querying with jq, sending to the Kubernetes API, or feeding into Terraform and CI/CD pipelines
Docker Compose
version: '3.9'
services:
web:
image: nginx:1.25-alpine
ports:
- '80:80'
- '443:443'
environment:
NGINX_HOST: example.com
NGINX_PORT: '80'
depends_on:
- db
restart: unless-stopped
db:
image: postgres:16-alpine
environment:
POSTGRES_DB: mydb
POSTGRES_USER: admin
POSTGRES_PASSWORD: secret
volumes:
- pgdata:/var/lib/postgresql/data
volumes:
pgdata: {} Convert a Docker Compose YAML to JSON for programmatic manipulation, feeding into automation scripts, or processing with JavaScript tooling
GitHub Actions Workflow
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run tests
run: pnpm test Parse a GitHub Actions workflow YAML to JSON to query specific fields, validate structure, or integrate with APIs that consume JSON
OpenAPI Spec
openapi: 3.0.3
info:
title: User API
version: 1.0.0
description: Manage application users
paths:
/users:
get:
summary: List users
operationId: listUsers
parameters:
- name: limit
in: query
schema:
type: integer
default: 20
responses:
'200':
description: Success
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/User'
/users/{id}:
get:
summary: Get user
operationId: getUser
parameters:
- name: id
in: path
required: true
schema:
type: string
responses:
'200':
description: Success
components:
schemas:
User:
type: object
properties:
id:
type: string
name:
type: string
email:
type: string
format: email Convert an OpenAPI 3.0 spec from YAML to JSON for use with client code generators, API testing tools, or programmatic schema inspection
Helm values.yaml
replicaCount: 3
image:
repository: my-app
tag: 1.0.0
pullPolicy: IfNotPresent
service:
type: ClusterIP
port: 80
ingress:
enabled: true
className: nginx
hosts:
- host: my-app.example.com
paths:
- path: /
pathType: Prefix
resources:
requests:
memory: 64Mi
cpu: 250m
limits:
memory: 128Mi
cpu: 500m
autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 10
targetCPUUtilizationPercentage: 80 Convert Helm chart values.yaml to JSON for analysis, generating reports, or feeding into tooling that expects JSON configuration
Ansible Playbook
- name: Configure web servers
hosts: webservers
become: true
vars:
http_port: 80
max_clients: 200
tasks:
- name: Ensure nginx is installed
ansible.builtin.package:
name: nginx
state: present
- name: Start nginx service
ansible.builtin.service:
name: nginx
state: started
enabled: true
- name: Copy nginx config
ansible.builtin.template:
src: nginx.conf.j2
dest: /etc/nginx/nginx.conf
owner: root
group: root
mode: '0644'
notify:
- Restart nginx
handlers:
- name: Restart nginx
ansible.builtin.service:
name: nginx
state: restarted Parse an Ansible playbook YAML to JSON for inspecting task structure, auditing configurations, or integrating with reporting pipelines
How to Use
- 1
Paste Your YAML
Enter or paste your YAML data into the input field above. You can also click 'Load example' to try a sample like a Kubernetes Deployment, Docker Compose file, or Helm values.yaml.
- 2
See Live JSON Output
JSON appears instantly in the output panel. Adjust Options (indent 2 or 4 spaces) to match your target tool's requirements.
- 3
Copy or Download
Click Copy to grab the JSON to your clipboard, or Download to save it as a .json file ready for jq, API calls, or any downstream tooling.
Common YAML Pitfalls
Tab Indentation
The YAML specification forbids tab characters for indentation — only spaces are allowed. If your YAML was written or copy-pasted from an editor that uses tabs, the parser will throw an error. Replace all tab indentation with spaces (2 or 4 spaces per level).
services: web: image: nginx:1.25-alpine
services:
web:
image: nginx:1.25-alpine Mismatched Indentation
YAML uses consistent indentation to define nesting. Mixing different numbers of spaces within the same block (e.g., 2 spaces at one level and 3 at another) causes parse errors. Each level must indent by the same number of spaces throughout the document.
metadata: name: my-app namespace: production
metadata: name: my-app namespace: production
Unquoted Special Characters
Characters like :, #, &, *, {, }, [, ], |, >, !, and @ have special meaning in YAML. Using them unquoted in values can cause parse errors or unexpected behavior. Quote values that contain these characters with single or double quotes.
url: http://example.com:8080/api tag: #latest
url: 'http://example.com:8080/api' tag: '#latest'
Anchor Cycles
YAML technically allows anchors that reference themselves (circular references), though this is rare in practice. A circular anchor causes the parser to enter an infinite expansion loop. The eemeli/yaml library detects and throws an error for circular anchors rather than hanging.
# Circular anchor (rare but possible) base: &base parent: *base
# Use explicit fields instead of circular references base: parent: null
Multi-Document Confusion
YAML files with multiple --- separators contain multiple documents. This tool returns only the first document as JSON. If you expected data from a later document (after the second or third ---), it will not appear in the output. Split your YAML on --- and convert each section separately if you need all documents.
# Only the first document is converted apiVersion: v1 kind: ConfigMap --- apiVersion: v1 kind: Secret
# Convert each document separately apiVersion: v1 kind: ConfigMap
Comment Loss
YAML supports # comments but JSON does not. All YAML comments are permanently dropped during conversion — this is a fundamental format difference, not a tool limitation. If you need to preserve annotations in JSON, encode them as a dedicated field such as a _comment key or a metadata object.
# This comment will be lost replicas: 3 # scale this up for production
replicas: 3 _comment: scale this up for production
Common Use Cases
- Kubernetes Manifest Analysis
- Convert Kubernetes YAML manifests to JSON for querying with jq, sending to the Kubernetes REST API, processing in Terraform data sources, or feeding into CI/CD pipelines that expect JSON.
- Docker Compose to JavaScript Tooling
- Parse Docker Compose YAML to JSON to extract service definitions, image names, port mappings, and environment variables for use in automation scripts, dependency graphs, or Node.js tooling.
- GitHub Actions API Integration
- Convert GitHub Actions workflow YAML to JSON to validate structure programmatically, extract job and step definitions, or integrate with CI/CD APIs that accept JSON workflow specifications.
- OpenAPI to Client Code Generation
- Many code generators (openapi-generator, swagger-codegen, oazapfts) accept OpenAPI specs in either format. Convert your YAML spec to JSON when a tool specifically requires JSON input or when you need to inspect it with JSON Schema validators.
- Helm Values Analysis
- Convert Helm chart values.yaml to JSON to generate reports, compare values across environments, feed into policy enforcement tools, or process with automation that expects JSON configuration.
- Config Migration to JSON-Based Tools
- Migrate application configuration from YAML (common in infrastructure tools) to JSON for use in JavaScript environments, REST APIs, AWS AppConfig, Azure App Configuration, or any system that stores configuration as JSON.
Technical Details
- YAML 1.2 Spec via parseAllDocuments with merge:true
- YAML is parsed using the eemeli/yaml library (v2.8+, CVE-safe) via parseAllDocuments with { version: '1.2', merge: true }. The YAML 1.2 schema ensures bare strings like yes and no are treated as strings (not booleans), matching the current YAML specification. The merge: true option fully expands anchor/alias merge keys (<<: *anchor) so the JSON output contains complete, dereferenced data. Multi-document YAML (--- separated) returns the first document.
- Anchor and Alias Expansion via Library
- The eemeli/yaml library handles anchor (&name) and alias (*name) expansion safely, including circular reference detection. All aliased data blocks — including merge key expansions — are fully inlined in the JSON output. This is the correct transformation because JSON has no reference or anchor concept. The library's safe expansion prevents infinite loops from malformed YAML.
- Browser-Based — No Upload, No Server
- All processing happens entirely in your browser's JavaScript engine. No data is transmitted over the network at any point. Inputs larger than 200KB automatically switch from live mode to manual mode (requiring an explicit Convert click) to keep the browser responsive and prevent main-thread blocking during heavy serialization.
Best Practices
- Use YAML 1.2-Compatible Syntax for Clean Conversion
- Author your YAML using YAML 1.2 conventions — quote yes, no, on, off, y, and n string values explicitly (e.g., enabled: 'yes') to avoid ambiguity. This tool parses with the YAML 1.2 schema (so these are strings), but older tools in your pipeline may use YAML 1.1 (where they become booleans). Explicit quoting in the source YAML is the safest practice across all parsers.
- Quote Large Numbers in YAML to Preserve Precision
- JavaScript cannot represent integers larger than 2^53 - 1 (9007199254740991) exactly. Kubernetes fields like resourceVersion and uid are int64 on the server and can exceed this limit. In your YAML source, quote these values (resourceVersion: '9007199254740993') so the parser treats them as strings, which are then preserved exactly in the JSON output as string values.
- Validate JSON Output Before Using in APIs
- After converting YAML to JSON, validate the result before sending it to an API, storing it, or processing it programmatically. Use our JSON Formatter to confirm the structure is correct. This is especially important for Kubernetes API calls, OpenAPI specs, and any JSON Schema-validated payload, where a structural error causes a confusing rejection at the API layer rather than at the conversion step.
- Separate Multi-Document YAML Before Converting
- If your YAML file contains multiple --- separated documents and you need all of them as JSON, split the file on --- first and convert each document individually. This tool takes only the first document. A simple approach: split on '\n---\n' in your editor or with awk, then paste each section separately.
- Use jq for Downstream JSON Processing
- Once you have JSON from your YAML, jq is the fastest way to query and transform it from the command line. Combine this tool with jq: convert your YAML online, paste the JSON, then use jq '.spec.replicas' or jq '.services | keys' to extract exactly what you need. For batch processing of many files, use the yq CLI with -o json flag directly.
Frequently Asked Questions
How do I convert YAML to JSON online?
How does this tool handle multi-document YAML (--- separator)?
How are YAML anchors and aliases (&anchor and *alias) handled?
Are YAML comments preserved in the JSON output?
How do I use this tool with a Kubernetes manifest?
How does this tool help with Docker Compose files?
What is the difference between YAML 1.1 and YAML 1.2, and which does this tool use?
Why does YAML forbid tab indentation?
Can large numbers lose precision when converting YAML to JSON?
How can I convert YAML to JSON on the command line?
Is my YAML data sent to any server when I use this tool?
Is there a file size limit for YAML input?
Related Tools
View all tools →Base64 Decoder & Encoder
Encoding & Formatting
Decode and encode Base64 online for free. Real-time conversion with full UTF-8 and emoji support. 100% private — runs in your browser. No signup needed.
JSON Formatter & Validator
Encoding & Formatting
Format, validate and beautify JSON instantly in your browser. Free online tool with syntax validation, error detection, minify and one-click copy. 100% private.
JSON to YAML Converter
Encoding & Formatting
Paste JSON, get YAML instantly. Live conversion in your browser. K8s/Compose-ready, 2/4-space indent, smart quoting. 100% private, no upload.
URL Encoder & Decoder with Built-in URL Parser
Encoding & Formatting
Decode or encode URLs in real time with built-in URL parser. Dual mode: encodeURI & encodeURIComponent. 100% private, no data sent to any server.
Number Base Converter — Binary, Hex, Decimal & Octal
Conversion Tools
Convert between binary, hex, decimal, octal and any base (2-36) instantly. Free, private — all processing in your browser.
Compress Images Online — JPEG, PNG & WebP
Conversion Tools
Compress JPEG, PNG & WebP up to 80% smaller — in your browser, no upload. Batch 20 images, adjust quality, compare before & after. Free & private.