YAML to JSON Converter
Convert YAML to JSON or JSON to YAML in your browser with one click.
Written by Golam Rabbani, Founder & Lead Engineer
How to use this yaml to json converter
- Select a conversion direction using the "YAML → JSON" or "JSON → YAML" toggle.
- Paste your YAML or JSON text into the source textarea.
- Press Convert to run the conversion.
- If the input is invalid, read the inline error message — it includes the line number where parsing failed.
- Copy the output to your clipboard using the Copy button, or press Reset to clear everything.
About this yaml to json converter
The YAML to JSON converter translates between two of the most widely used data serialisation formats without sending your text to a server. Paste YAML and get back formatted JSON, or paste JSON and get back clean YAML — the direction toggle switches the mode on the fly.
YAML and JSON represent the same underlying data model — mappings (key-value pairs), sequences (arrays), and scalars (strings, numbers, booleans, null) — but they use completely different syntax. JSON uses curly braces, square brackets, commas, and quoted keys. YAML uses indentation and dashes to express the same structure, which makes it popular for configuration files where readability matters. The tool parses the source into an in-memory value tree, then serialises that tree in the target format. For YAML input the parser handles block mappings, block sequences, inline scalars, quoted strings, and comment stripping. YAML comments (lines starting with #) are silently dropped because JSON has no comment syntax. For JSON input the built-in JSON.parse handles the decode, and the tool emits idiomatic block-style YAML with two-space indentation. The parser supports the common YAML subset — mappings, sequences, scalars, and nesting via indentation — but not anchors, aliases, tags, or flow-style collections.
For example, the YAML snippet "name: site\nport: 8080\ntags:\n - prod\n - api" converts to {"name":"site","port":8080,"tags":["prod","api"]} (pretty-printed with two-space indent). The same JSON converts back to the original YAML block structure. This is useful for Kubernetes manifests, GitHub Actions workflows, Ansible playbooks, and any situation where a tool requires one format but your source file is in the other. All processing runs in-browser — no upload, no account, no data leaves your machine.
FAQ
- What is the difference between YAML and JSON?
- Both formats represent the same data model — mappings, arrays, and scalars — but YAML uses whitespace indentation and dashes instead of braces, brackets, and commas. YAML is easier to read and write by hand; JSON is stricter and more widely supported by APIs and language parsers.
- Which YAML features does the YAML to JSON converter NOT support?
- The parser covers block mappings, block sequences, scalars (strings, numbers, booleans, null), quoted strings, and nested indentation. It does not support YAML anchors (&), aliases (*), explicit tags (!!), merge keys (<<), or flow-style collections ({} and []) inline in YAML input.
- Do YAML comments survive the conversion to JSON?
- No. JSON has no comment syntax, so all YAML comments (# …) are stripped during parsing and do not appear in the JSON output. When converting JSON back to YAML the output also contains no comments, since the source JSON has none.
- Is the key order preserved when converting between formats?
- Key insertion order is preserved as it appears in the source. The tool iterates object entries in the order they were parsed, so the output mapping follows the same sequence as the input — no alphabetical sorting is applied.