YAML to JSON Converter — Convert YAML to JSON Online Free
Convert YAML to valid JSON using AI. Handles anchors, aliases, multi-line strings, and complex YAML structures. Outputs properly formatted JSON. Free, no sign-up.
Related Guides
YAML to JSON Converter — Convert YAML to JSON Online Free
About YAML to JSON Converter — Convert YAML to JSON Online Free
This free online YAML to JSON converter instantly transforms YAML documents into valid, properly formatted JSON, handling nested objects, arrays, multi-line strings, and YAML-specific types like anchors and aliases. Developers use it to bridge configuration files, convert Kubernetes or Docker Compose manifests for API consumption, and debug YAML parsing errors by seeing the equivalent JSON structure.
YAML to JSON Type Mapping
| YAML Type | YAML Example | JSON Output | JSON Type |
|---|---|---|---|
| String | name: Alice | "name": "Alice" | string |
| Integer | port: 8080 | "port": 8080 | number |
| Float | ratio: 1.5 | "ratio": 1.5 | number |
| Boolean (true) | enabled: true | "enabled": true | boolean |
| Boolean (false) | debug: false | "debug": false | boolean |
| Null | value: null | "value": null | null |
| Null (tilde) | value: ~ | "value": null | null |
| Sequence | tags: [a, b] | "tags": ["a", "b"] | array |
| Block sequence | - item1\n- item2 | ["item1", "item2"] | array |
| Mapping | user:\n id: 1 | {"user": {"id": 1}} | object |
| Multi-line string (|) | bio: |\n line1 | "bio": "line1\n" | string |
| Multi-line string (>) | bio: >\n line1 | "bio": "line1 " | string |
| Anchor & alias | a: &x 1\nb: *x | {"a": 1, "b": 1} | number |
| Explicit string tag | val: !!str 42 | "val": "42" | string |
| Explicit int tag | val: !!int '7' | "val": 7 | number |
YAML vs JSON Format Comparison
| Feature | YAML | JSON |
|---|---|---|
| Syntax | Indentation-based | Brace/bracket-delimited |
| Comments | Supported (# prefix) | Not supported |
| String quotes | Optional for simple strings | Required (double quotes only) |
| Trailing commas | N/A | Not allowed |
| Multi-line strings | Native (| and > block scalars) | Escape sequences only (\n) |
| Anchors / aliases | Supported (&anchor, *alias) | Not supported |
| Binary data | !!binary tag (Base64) | Not natively supported |
| Dates | Implicit ISO-8601 parsing | String only |
| File extension | .yaml or .yml | .json |
| Human readability | High — minimal punctuation | Moderate — more punctuation |
| Parser availability | Most languages via libraries | Built into every runtime |
| Spec version | YAML 1.2 (2009) | ECMA-404 / RFC 8259 (2017) |
| Used in | Kubernetes, CI/CD, Ansible, Docker Compose | REST APIs, config files, data exchange |
Frequently Asked Questions
Does YAML support comments and will they appear in the JSON output?
YAML supports single-line comments starting with #, but JSON has no comment syntax. When converting YAML to JSON, all comments are stripped from the output. If you need to preserve annotation data, move it into a dedicated JSON field such as "_comment" before converting.
How are YAML anchors and aliases converted to JSON?
YAML anchors (&name) and aliases (*name) are dereferenced during conversion — each alias is replaced with a full copy of the anchored value. The resulting JSON contains no anchor or alias syntax, just the expanded data. This means a large anchor reused many times will produce repeated data in the JSON, which may increase file size.
Why does my YAML boolean convert to a string instead of true/false in JSON?
YAML 1.1 recognized values like yes, no, on, off, and y/n as booleans, but YAML 1.2 (the current spec) only treats true and false as booleans. Parsers following YAML 1.1 (common in older Ruby and Python libraries) will convert yes to true in JSON, while YAML 1.2 parsers output "yes" as a string. Wrap ambiguous values in quotes in your YAML source to guarantee string output.
How are multi-line YAML strings (block scalars) converted to JSON?
YAML literal block scalars (|) preserve newlines as \n in the JSON string value. Folded block scalars (>) collapse newlines into spaces, so each paragraph becomes a single space-separated line in JSON. The final newline behavior is controlled by the chomping indicator: - strips trailing newlines, + keeps them, and the default keeps exactly one.
Can I convert a multi-document YAML file (with --- separators) to JSON?
A YAML file can contain multiple documents separated by --- (and optionally ended with ...). Standard JSON has no multi-document format, so most converters either output only the first document or produce a JSON array where each element is one document. Check your converter's behavior; this tool wraps multiple documents into a JSON array to keep all data accessible.
If jsondecode.com saved you time, share it with your team
Free forever. No ads. No sign-up. Help other developers find it.