Paste YAML or drop a .yaml file and convert it to formatted JSON as you type.
Paste YAML, upload a .yaml or .yml file or drop one here.
Updates as you type. Copy it or download a .json file.
Converting…
This free YAML to JSON converter turns a YAML document into formatted JSON that you can paste into an API client, a test fixture or a script. Paste your text, or open a .yaml or .yml file, and the JSON appears as you type. Nothing to install, no sign-up, and your data stays in your browser instead of being uploaded.
It is built for the files developers actually have: Kubernetes manifests, Docker Compose and GitHub Actions workflows, OpenAPI specs and application config. Anchors, aliases and merge keys are resolved, files with several --- documents are supported, and a syntax error is reported with its line and column rather than a blank output.
.yaml or .yml file. You can also drag a file onto the editor.at line 4, column 4.yes and no being booleans.data.json.Mappings become objects, sequences become arrays, and the | block keeps its line breaks. The merge key << copies the defaults into service, and the country code NO stays the string "NO". The comment is not part of the output because JSON has no comments.
# Shared defaults
defaults: &defaults
replicas: 2
region: NO
service:
<<: *defaults
name: orders-api
ports: [80, 443]
debug: false
motd: |
Welcome
back{
"defaults": {
"replicas": 2,
"region": "NO"
},
"service": {
"replicas": 2,
"region": "NO",
"name": "orders-api",
"ports": [
80,
443
],
"debug": false,
"motd": "Welcome\nback\n"
}
}| YAML | JSON output | Notes |
|---|---|---|
| Mapping | Object | Keys stay in the order they appear. |
| Sequence | Array | Both - item lists and [a, b] flow style. |
| Plain, quoted and block strings | String | Block scalars | and > keep or fold line breaks. |
| Integers and floats | Number | 0x1F becomes 31 and 1e3 becomes 1000. |
true / false | Boolean | yes, no, on and off stay strings unless YAML 1.1 is ticked. |
null, ~ | null | A key with no value is null too. |
| Dates and timestamps | String | Written exactly as they appear in the YAML. |
| Anchors, aliases, merge keys | Expanded copies | JSON has no references, so the data is repeated. |
Several --- documents | Array | One element per document. |
| Comments | Dropped | JSON cannot hold comments. |
An anchor (&defaults) names a value and an alias (*defaults) reuses it. The converter replaces every alias with a full copy of the anchored value. The merge key << works the same way for mappings: it can take one alias or a list of them, and keys you write directly under it override the merged ones. A file that refers to an anchor that does not exist, or an anchor that contains itself, is rejected with an error. So is one that expands into an unreasonable number of copies, which is how a "billion laughs" file would hang a parser.
Kubernetes and Helm output often put several resources in one file, separated by ---. JSON allows only a single top-level value, so the converter wraps the documents in an array. A file with one document, including one that starts with a --- line, is not wrapped. Empty documents are skipped, so a trailing separator does not add a null.
kind: Service --- kind: Deployment
[
{
"kind": "Service"
},
{
"kind": "Deployment"
}
]By default the file is read as YAML 1.2, the current version, where only true and false are booleans. That means enabled: yes becomes the string "yes" and a country code like NO stays text. Many tools still follow YAML 1.1, including PyYAML and the parsers behind Kubernetes and Ansible, where yes, no, on, off and a lone y or n are booleans. If your file was written for one of those tools, tick Read as YAML 1.1. That mode also reads values like 1:30 as numbers (90), and turns dates into full ISO timestamps.
In YAML 1.2, a value like 2024-01-15 is just a string, and it stays one in the JSON. Only an explicit !!timestamp tag, or YAML 1.1 mode, converts it into an ISO 8601 string such as 2024-01-15T00:00:00.000Z. Integers larger than 253 keep all their digits instead of being rounded the way a JavaScript number would be. YAML's .inf and .nan have no JSON equivalent and become null.
JSON object keys are always strings, so a key like 1, true or null is written as "1", "true" or "null". A key that is itself a list or mapping becomes its compact JSON text. Tagged values are converted too: !!binary becomes a base64 string, !!set becomes an array and !!omap becomes an object. Custom tags such as CloudFormation's !Ref are ignored and the value underneath is kept, so !Ref MyBucket turns into "MyBucket".
A mapping that repeats a key is reported as an error instead of silently keeping the last value, because that is almost always a mistake in the file. Other problems, such as a tab used for indentation, an unclosed bracket or a stray colon, are reported with the line and column from the top of your input, including in later documents of a multi-document file.
Need the opposite direction? The JSON to YAML converter turns JSON back into readable YAML. If you work with other config formats, there is also a TOML to JSON converter and an XML to JSON converter, and the JSON to TypeScript converter can generate types from the result. To check the converted data against a contract, build a schema with the JSON Schema generator, or create test data with the JSON Generator. For a longer look at the trade-offs between the two formats, read YAML vs JSON.
Paste your YAML into the YAML Input editor, or upload a .yaml or .yml file. The JSON appears in the output editor as you type. Copy it, or click Download to save it as data.json.
Nearly. YAML 1.2 was designed so that valid JSON is also valid YAML, which is why this converter accepts JSON as input. The reverse is not true: comments, anchors, multiple documents and non-string keys have no JSON equivalent, so the converter drops or rewrites them.
A file with one document becomes that document's JSON value. A file with several documents separated by --- becomes a JSON array with one element per document, because a JSON file can only hold one value. Empty documents, such as one left by a trailing ---, are skipped.
Yes. Aliases (*name) are replaced with a copy of the anchored value (&name), and merge keys (<<) are expanded into the surrounding mapping, with keys written locally taking priority. JSON has no references, so the output contains the full data.
The converter reads YAML 1.2, where only true and false are booleans. Older YAML 1.1 parsers, such as PyYAML, also treat yes, no, on and off as booleans. If your file was written for one of those, tick Read as YAML 1.1 to get the same result.
No. The conversion runs entirely in your browser with JavaScript, so your data never leaves your device. That makes it safe to use with config files that contain internal hostnames or other private values.
Yes. Use the JSON to YAML converter, or click Swap direction above the editors. Converting YAML to JSON and back keeps the data, although comments and anchors are lost along the way.