JSON ↔ YAML Converter

Convert JSON to YAML or YAML to JSON instantly — paste either format, auto-detected. Supports nested objects, arrays, multi-line strings, flow style and all scalar types.

Direction:
Indent:
Samples:
INPUT
OUTPUT

JSON vs YAML — Key Differences

Both JSON and YAML are data serialization formats used to represent structured data. YAML is a superset of JSON — every valid JSON document is also valid YAML 1.2. The two formats are interchangeable in most contexts, but have different strengths:

FeatureJSONYAML
CommentsNot supportedSupported (#)
VerbosityMore punctuation ({}, [], "")Minimal — relies on indentation
Multi-line stringsMust escape newlines as \nLiteral (|) and folded (>) block scalars
Data typesString, Number, Boolean, Null, Array, ObjectAll of JSON + timestamps, binary, custom tags
Anchors & aliasesNo — content must be repeatedYes — define once, reference with *alias
Human readabilityGood for small payloadsExcellent for large configs
Machine parsingSimpler, fasterMore complex, multiple spec versions
Common use casesREST APIs, web apps, databasesConfig files (K8s, Docker Compose, CI/CD, Ansible)

How This JSON to YAML Converter Works

The converter runs entirely in your browser — no data is sent to a server. It handles both directions:

YAML Scalar Types and Their JSON Equivalents

YAML infers types from the value syntax. Understanding this avoids surprises when converting:

YAML valueJSON typeNotes
42number (integer)
3.14number (float)
true / True / TRUEboolean trueAll three are valid
false / False / FALSEboolean false
null / Null / NULL / ~null
"42"string "42"Quotes force string type
0x1Fnumber 31Hexadecimal literal
.inf / .InfInfinity (not valid JSON)JSON has no Infinity literal
.nan / .NaNNaN (not valid JSON)JSON has no NaN literal
2001-01-23string (timestamp)YAML 1.1 parsed as date; YAML 1.2 treats as string

YAML Multi-line String Styles

YAML provides two block scalar indicators for multi-line strings — critical when converting from JSON strings that contain newlines:

This converter always uses the literal block style (|) for JSON strings containing \n characters.

Conversion Examples

Kubernetes Deployment (YAML → JSON)

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app
  labels:
    app: my-app
spec:
  replicas: 3
  selector:
    matchLabels:
      app: my-app

This typical Kubernetes manifest converts cleanly to JSON, with all nested keys preserved.

OpenAPI Info Object (JSON → YAML)

{
  "openapi": "3.0.0",
  "info": {
    "title": "Pet Store API",
    "version": "1.0.0",
    "description": "A sample API"
  },
  "servers": [
    { "url": "https://api.example.com/v1" }
  ]
}

JSON APIs often need to be converted to YAML for OpenAPI spec files used by tools like Swagger UI, Redoc, or Stoplight.

Boolean & Null Handling

# YAML input
debug: true
database: null
retries: 3
ratio: 0.75
name: "true"   # quoted → stays a string

YAML's unquoted true, false, and null become JSON's native true, false, and null. Quoting them forces the string type.

Frequently Asked Questions

Yes, in YAML 1.2. JSON is a subset of YAML 1.2, so a conforming YAML 1.2 parser can parse any valid JSON. YAML 1.1 (used by older parsers like PyYAML by default) has some incompatibilities — for example, it treats on, off, yes, no as booleans, while JSON and YAML 1.2 treat them as strings.

YAML was designed to be maximally human-readable. Indentation eliminates the visual noise of braces, brackets, and quotes, making config files easier to read and write by hand. The trade-off is that indentation errors are harder to spot than mismatched braces, and YAML parsers are significantly more complex to implement than JSON parsers.

The following YAML features are not handled: anchors and aliases (&anchor / *alias), custom tags (!!python/object), merge keys (<<: *defaults), multi-document streams (only the first document is parsed), and complex keys (non-string mapping keys). For these features, use a full YAML library such as js-yaml (JavaScript), PyYAML or ruamel.yaml (Python), or gopkg.in/yaml.v3 (Go).

Wrap the value in quotes. For example, version: "1.10" stays a string, while version: 1.10 becomes the number 1.1 (trailing zero dropped by float parsing). This is especially important for version strings, phone numbers, zip codes, and IDs that happen to look like numbers.

| (literal block scalar) preserves newlines exactly as written. > (folded block scalar) collapses single newlines into spaces — only blank lines create actual newlines. Use | for code, shell scripts, or any content where newlines matter. Use > for long prose descriptions where you want word wrapping in the YAML file but a single paragraph in the output.

Yes. YAML supports .inf (infinity), -.inf (negative infinity), and .nan (not-a-number), which have no JSON equivalents. When converting YAML containing these values to JSON, this converter renders them as the strings "Infinity", "-Infinity", and "NaN" to avoid producing invalid JSON. YAML also supports binary data, timestamps, and arbitrary custom types via tags.

The indent setting (2 or 4 spaces) only affects the output of this converter. When converting YAML → JSON and back to YAML, the output indent is determined by the "Indent" toggle at the top, regardless of the original YAML's indent. YAML allows any consistent indentation — 2 and 4 spaces are both valid and commonly used.

All conversion runs locally in your browser using JavaScript. No data is transmitted to any server. The page has no analytics, no data collection, and no server-side processing. You can safely paste secrets, API keys, and internal configuration files — nothing leaves your machine.