Convert YAML to JSON online
What changes when you convert YAML to JSON online: lost comments, expanded anchors, type surprises like yes and NO, and when to keep YAML or convert locally.
Converting YAML to JSON online usually takes a paste and a click. Whether the result is usable depends on what your YAML contains and where the JSON is going. This review explains what the conversion changes, where meaning can shift without any visible error, and when you are better off keeping the original YAML or converting on your own machine. No specific online converter was tested for this article, so treat tool behavior described here as typical, and verify it against your own sample.
Is converting YAML to JSON suitable for your use?
For most configuration and data files, conversion works. YAML 1.2 was designed so that JSON fits inside its data model, so ordinary mappings, lists, strings, numbers, booleans and nulls carry over directly. The main benefit is that JSON is accepted by almost every programming language, API and validator, and it has a much smaller grammar. That makes it easier to parse consistently and to check against a schema.
The decisive tradeoff is that conversion is one-way in practice. Comments disappear, anchors and aliases are expanded into copies, and unquoted values can be interpreted differently depending on which YAML version the converter follows. Keep the YAML file as your source of truth when people edit it by hand, when comments carry meaning, or when another tool expects YAML. Convert to JSON only when a consumer specifically needs JSON. Then regenerate the JSON from the YAML each time instead of editing both.
What the conversion actually changes
This is a change of serialization format, not a visual or character-level transformation. The converter parses the YAML text into a data structure of maps, lists and scalar values, then writes that structure out using JSON syntax. Nothing is reversed, mirrored or restyled, and no Unicode lookalike characters are introduced. What changes is the stored text: indentation-based structure becomes braces and brackets, keys and strings gain double quotes, and anything in the YAML that is not part of the data model is dropped or resolved.
| YAML feature | What happens in JSON |
| Comments (# ...) | Removed; JSON has no comment syntax |
| Anchors (&name) and aliases (*name) | Expanded into full copies of the referenced data |
| Merge keys (<<: *name) | Merged into the mapping if the parser supports them; otherwise an error or a literal "<<" key |
| Block scalars (| and >) | Become single strings with \n escapes; folded (>) text joins lines with spaces |
| Multiple documents separated by --- | JSON holds one value, so tools may keep only the first, wrap all in an array, or refuse |
| Non-string keys (numbers, booleans, complex keys) | JSON keys must be strings, so they are stringified or rejected |
| Dates and timestamps | JSON has no date type; they become strings, or the conversion fails |
| Custom tags (!something) | Ignored, rejected or converted unpredictably |
| Duplicate keys | Invalid YAML; some parsers raise an error, others silently keep the last value |
Type interpretation: the change you may not notice
The riskiest changes involve unquoted values whose type depends on the parser. YAML 1.1 treats words such as yes, no, on, off, y and n (in various capitalizations) as booleans, and reads numbers with a leading zero as octal. The YAML 1.2 core schema limits booleans to true and false and reads leading-zero numbers as decimal. Many widely used libraries still follow YAML 1.1 rules, and an online converter rarely says which version it follows. The same input can therefore produce different JSON:
service: api
enabled: yes
country: NO
version: 1.10
mode: 0755
ports:
- 80
- 443
A parser following YAML 1.1 rules would produce output equivalent to the first line below. A parser using the YAML 1.2 core schema would produce the second:
{"service": "api", "enabled": true, "country": false, "version": 1.1, "mode": 493, "ports": [80, 443]}
{"service": "api", "enabled": "yes", "country": "NO", "version": 1.1, "mode": 755, "ports": [80, 443]}
Both versions agree on one thing: 1.10 becomes the number 1.1, so a version label loses its trailing zero. The country code for Norway becomes false under 1.1 rules, and the file mode 0755 becomes 493. To prevent all of these, quote any value that must stay a string, such as "1.10", "NO" or "0755".
Anchors and multi-line strings
Anchors let YAML reuse a block. JSON has no references, so the converter writes out a full copy each time. The output stays correct, but it gets longer, and an edit to the JSON no longer propagates to the other copies:
defaults: &defaults
timeout: 30
primary:
<<: *defaults
host: primary-db
{"defaults": {"timeout": 30}, "primary": {"timeout": 30, "host": "primary-db"}}
A literal block scalar keeps its line breaks, but in JSON they appear as escape sequences on one line. By default, a single trailing newline is also kept:
description: |
Line one
Line two
{"description": "Line one\nLine two\n"}
Will the JSON stay readable and usable after copying or sharing?
JSON output is plain text, so it survives copy and paste far better than styled or decorated text. Paste problems usually come from the destination, not the converter. Word processors, some chat apps and some note-taking tools replace straight quotes with curly quotes, which makes the JSON invalid. Paste into a code editor, a plain-text field or a code block. If the result will not parse, check the quote characters first.
Other usability limits to check:
- Large integers: JSON text can hold any integer, but converters running in JavaScript store numbers as double-precision floats. Integers above 9007199254740991 may be rounded silently. Quote long IDs in the YAML if exact digits matter.
- Non-ASCII text: some converters write characters such as accented letters or emoji as \u escape sequences. Emoji outside the Basic Multilingual Plane become pairs of escapes. The data is the same, but it is harder for a person to read.
- Key order: most converters keep the YAML key order, but the JSON specification treats objects as unordered. Do not rely on order in a downstream consumer.
- Readability: deeply nested JSON with long escaped strings is harder to scan and edit than the equivalent YAML. Choose an indented (pretty-printed) output option if people will read it.
Assistive technology reads JSON as ordinary characters, so it does not have the problems that Unicode-styled or reversed text causes for screen readers. Heavy punctuation and deep nesting can still make JSON tedious to listen to or navigate. No screen reader was tested with JSON output for this article. If people will review the data rather than software, the original YAML or a summary in prose is usually easier for them.
Using a converter as a YAML validator
Because the converter must parse the YAML first, a successful conversion shows the file is syntactically valid to that parser. A failure usually points to a line with the problem. Common causes are tab characters used for indentation (YAML does not allow them), inconsistent indentation, a missing space after a colon, or an unquoted value that starts with a reserved character such as @ or a backtick.
Valid syntax is not the same as correct data. A file can parse cleanly and still turn NO into false. Compare the JSON output against what you intended, value by value for anything type-sensitive. If you have a JSON Schema, validate the JSON against it.
Privacy: what you can and cannot conclude
You cannot tell from a converter's page whether your input stays in your browser or is sent to a server. A clean design or a phrase like "secure" proves nothing either way, and no specific tool's handling or retention practices were checked for this article. Unless you have verified it yourself, assume pasted content may leave your device. You can verify by reading a published privacy policy, or by watching your browser's network activity while converting and confirming nothing is uploaded. YAML configuration files often hold passwords, API tokens, connection strings or internal hostnames. Remove those before using an online tool, or convert locally.
Converting locally instead
For sensitive files or repeated conversions, a local command avoids the privacy question and makes the parser explicit. With Python and the PyYAML library installed, this one-liner prints indented JSON. PyYAML follows YAML 1.1 rules, so values like yes and NO become booleans. The default=str argument turns dates into strings instead of raising an error:
python3 -c 'import sys, yaml, json; print(json.dumps(yaml.safe_load(sys.stdin), indent=2, default=str))' < config.yaml
Command-line YAML processors such as yq can do the same conversion. Check which YAML version and schema your version uses before relying on its type handling.
Quick checklist before you rely on the output
- Quote any value that must remain a string: version numbers, country codes, zip codes, IDs with leading zeros, and words like yes, no, on and off.
- Check whether the input contains multiple documents, custom tags, dates or non-string keys, and confirm how the converter handled them.
- Compare a few type-sensitive values in the output against the source.
- Keep the YAML as the editable source when comments or anchors matter, and regenerate the JSON rather than editing it by hand.
- Remove secrets before pasting into any online tool whose data handling you have not verified.
- Paste the result into a plain-text destination to avoid curly-quote substitution.
What this review could not confirm
No specific online converter was examined, so this review cannot say which tools follow YAML 1.1 or 1.2 rules, how a given tool handles multiple documents or merge keys, or whether any tool processes data only in the browser. The input and output examples follow the documented behavior of the two YAML rule sets. They are not captured from a particular tool. Run your own representative file through the converter you plan to use, and judge it on that result.