What is the YAML to JSON Converter?
This tool converts YAML to JSON and JSON back to YAML. The two formats describe the same data model, so conversion is mostly mechanical, but YAML has several features and pitfalls that JSON does not, and those are where conversion gets interesting.
YAML was designed for human authorship. It uses indentation instead of braces, does not require quotes around most strings, and supports comments, all of which make it pleasant for configuration files. JSON, by contrast, is stricter and simpler, which makes it better suited to machine interchange.
Because YAML is a superset of JSON in practice, any valid JSON document is also valid YAML. The reverse is not true: YAML supports anchors, aliases, multiple documents in one file, and comments, none of which have a JSON equivalent.
YAML's implicit typing is the main source of surprises. Unquoted values are interpreted according to their appearance, so a version number written as 1.10 becomes the number 1.1, and in older YAML versions unquoted no and off were interpreted as booleans. Quoting values you intend as strings avoids all of this.
How to use the YAML to JSON Converter
- Paste YAML or JSON. The tool detects which format you have supplied.
- Choose the conversion direction. Convert YAML to JSON, or JSON to YAML.
- Review the output. Check that implicitly typed values came through as the types you intended.
- Copy or download. Take the converted document into your editor or pipeline.
Worked examples
YAML to JSON
Indentation-based nesting becomes explicit braces and brackets. Comments are dropped, because JSON has no way to represent them.
# Service configuration
name: api-server
port: 8080
replicas: 3
env:
- name: LOG_LEVEL
value: debug
- name: REGION
value: eu-west-1{
"name": "api-server",
"port": 8080,
"replicas": 3,
"env": [
{ "name": "LOG_LEVEL", "value": "debug" },
{ "name": "REGION", "value": "eu-west-1" }
]
}The comment is lost in conversion, JSON does not support comments.
Implicit typing pitfalls
Unquoted YAML values are typed by inspection, which produces results that surprise people regularly.
version: 1.10
enabled: yes
country: NO
zip: 01234
time: 12:30version -> 1.1 (number, trailing zero lost)
enabled -> true (boolean in YAML 1.1)
country -> false (NO parsed as boolean!)
zip -> 668 (parsed as octal in YAML 1.1)
time -> 750 (parsed as sexagesimal)
Quote these values to keep them as strings.Common use cases
- Working with Kubernetes manifests. Kubernetes resources are authored in YAML but the API consumes JSON, so converting helps when debugging what will actually be submitted.
- Migrating configuration formats. Moving a project between YAML and JSON configuration is a mechanical conversion.
- Inspecting CI pipeline definitions. Converting a complex GitHub Actions or GitLab CI file to JSON makes its true structure explicit.
- Preparing API payloads. Authoring a request body in YAML is more comfortable, then converting to JSON for the actual request.
Features and limitations
- Converts in both directions between YAML and JSON.
- Preserves nesting, arrays, and scalar types.
- Reports parse errors with position information.
- Comments are lost when converting to JSON, since JSON has no comment syntax. This is a limitation of the format, not the tool.
- Anchors and aliases are expanded rather than preserved, and multi-document YAML files need to be converted one document at a time.
Frequently asked questions
Why did my version number change?
Unquoted 1.10 is parsed as a floating-point number, and 1.10 equals 1.1 numerically, so the trailing zero disappears. Quote it as "1.10" to keep it a string.
Why is my country code NO showing as false?
In YAML 1.1, unquoted no, off, and n are boolean false, so the Norway country code becomes a boolean. This is the classic 'Norway problem'. Quoting the value prevents it.
What happens to my comments?
They are discarded when converting to JSON, because JSON has no comment syntax. Converting back to YAML will not restore them, so keep the YAML source as your original.
Is JSON valid YAML?
In practice yes, YAML 1.2 is a superset of JSON, so a YAML parser will accept a JSON document. The reverse does not hold, since YAML has many constructs JSON cannot express.
Which should I use for configuration?
YAML when humans edit the file often and comments are valuable. JSON when machines produce and consume it, or when you want to avoid YAML's implicit typing surprises entirely.
Is my configuration uploaded?
No. Conversion runs in your browser, which matters since configuration files often contain hostnames, credentials, and internal details.
All processing happens locally in your browser, your data never leaves your device.
