Free YAML to JSON converter

Content last reviewed:

Paste your YAML configuration and the tool returns it as JSON indented with two spaces. The entry port: 8080 comes back as an object with one pair, and a file holding several manifests split by a --- line becomes an array. Everything runs in your browser.

to

What is YAML and what is JSON?

YAML is the format used to write down how software should run: service addresses, server counts, environment variables. The name is an acronym that expands into itself — “YAML Ain't Markup Language”[1]. Indentation carries the structure: whatever sits deeper belongs to the key above it. A single entry is a name, a colon and a value, such as port: 8080.

CSS code on an editor screen with a @keyframes rule, indentation and name: value pairs
CSS code on an editor screen. Both mechanisms are visible at once: the name: value pairs separated by a colon that YAML uses, and the curly braces closing a block that JSON uses. Each further indent shows that the line belongs to the block above. Photo: Pankaj Patel, Unsplash.

JSON (JavaScript Object Notation) carries data between programs, and it is the shape APIs answer in. RFC 8259 from the IETF (Internet Engineering Task Force) allows six kinds of value: object, array, string, number, boolean and null[2]. Curly braces open an object, square brackets open an array, and every key name sits in double quotes. XML held that role earlier, and data from an older interface goes through the XML to JSON converter.

Release 1.2 of the YAML specification set itself the goal of making YAML a strict superset of JSON[1]. In practice that means you can paste a JSON file into the left box of this converter and the tool reads it the same way it reads YAML, returning the same data indented with two spaces.

How do you convert YAML to JSON?

Paste your YAML into the left box and click Convert. JSON indented with two spaces appears on the right. The entry port: 8080 comes back as {"port": 8080}, each further level of indentation becomes a nested object, and a dash list turns into an array.

To take a file from disk, use the Add YAML file link above the input box; it accepts .yaml and .yml. Move the result on with Copy or save it with Download, which names the file converted.json. Clear all empties both boxes. Below the tool sits a source and target format picker leading to neighbouring pairs — the CSV to JSON converter, for instance, when the data arrives from a spreadsheet.

The conversion runs in your browser, so the configuration file stays on your computer. That matters with this format, because YAML files hold access keys and database passwords alongside service names.

What does the converter do with values, dates and multiple documents?

The converter reads data according to the core schema from release 1.2 of the YAML specification, which the specification itself calls the recommended default[1]. Only true, True, TRUE, false, False and FALSE are booleans there. The words yes, no, on and off behave like ordinary text and reach the result in quotes. The full set is collected in the table of boolean spellings on this page.

The same rule covers numbers and settles three spellings. The first is a leading zero: 01234 gives the number 1234 in base ten, because base eight has its own 0o prefix in this release. The second is a version number: written without quotes, 1.10 is a number and comes back as 1.1, so write values of that kind in quotes in the source file. The third is a date: the core schema has no date type, so 2024-01-15 reaches the result as the text "2024-01-15", written exactly as in the file.

An anchor and an alias, the & and * spellings, are expanded: every reference gets a full copy of the data in the result. The merge key << works the same way, so a block inheriting from a base configuration holds the complete set of fields in JSON, including the ones it overrode itself. Comments opened with # stay in the source file: RFC 8259 lists six kinds of JSON value and a comment sits outside that list[2].

A file holding several documents is handled separately. The Kubernetes documentation describes grouping multiple resources in one file, separated by a --- line[3], and that is the shape a manifest bundle and the output of helm template take. The converter reads each such document on its own and collects them into a single JSON array, in file order. An empty document after a closing --- line is skipped, so a file with one resource and a trailing separator still gives a single object.

A row of cooling fan modules in a data centre with pipework running alongside
A wall of cooling fans in a data centre. How many machines serve an application is decided by the number written at the replicas key in a Kubernetes manifest, and that manifest is a YAML file. Photo: Winston Chen, Unsplash.

The result is ready for the next tool in line. A list of records goes into a spreadsheet through the JSON to CSV converter, and the way back, from JSON to a readable configuration, is handled by the JSON to YAML converter. When the system on the other side takes XML only, the JSON to XML converter prepares the data.

What does every YAML spelling look like in JSON?

Spelling in the YAML fileYAML exampleResult in JSON
Name and value pairport: 8080{"port": 8080}
Nesting through indentationservice: port: 8080{"service": {"port": 8080}}
Dash listports: - 80 - 443{"ports": [80, 443]}
List in square bracketsports: [80, 443]{"ports": [80, 443]}
Booleandebug: true{"debug": true}
The word yes without quotesdebug: yes{"debug": "yes"}
Country code for Norwaycountry: NO{"country": "NO"}
Number with a leading zerocode: 01234{"code": 1234}
Number larger than 9,007,199,254,740,991id: 12345678901234567890{"id": 12345678901234567890}
Version number without quotesversion: 1.10{"version": 1.1}
Key with no valuenotes:{"notes": null}
Datereleased: 2024-01-15{"released": "2024-01-15"}
Multi-line textnotes: | first line second line{"notes": "first line\nsecond line\n"}
Text folded into one linenotes: > first line second line{"notes": "first line second line\n"}
Comment above an entry# application port port: 8080{"port": 8080}
Anchor and aliasbase: &b {cpu: 2} prod: *b{"base": {"cpu": 2}, "prod": {"cpu": 2}}
Merge key with an overridebase: &b cpu: 2 ram: 1Gi prod: <<: *b cpu: 4{"base": {"cpu": 2, "ram": "1Gi"}, "prod": {"cpu": 4, "ram": "1Gi"}}
Two documents in one filekind: Service --- kind: Deployment[{"kind": "Service"}, {"kind": "Deployment"}]
Every row is a result from this converter measured on 17 September 2026. The results are written on one line, and the tool adds two-space indentation to them. A number larger than 9,007,199,254,740,991 is copied unchanged in Chrome and Edge from version 114, in Firefox from version 135 and in Safari from version 18.4, while older browsers round its last digits.

Which YAML spellings are booleans and which are text?

Spelling in the YAML fileResult in JSONKind of value
true, True, TRUEtrueboolean
false, False, FALSEfalseboolean
yes, Yes, YES"yes", "Yes", "YES"text
no, No, NO"no", "No", "NO"text
on, On, ON"on", "On", "ON"text
off, Off, OFF"off", "Off", "OFF"text
y, n, Y, N"y", "n", "Y", "N"text
tRue, FaLse and other mixed spellings"tRue", "FaLse"text
null, Null, NULL, ~nullempty value
a key with no valuenullempty value
The set matches the core schema from release 1.2 of the YAML specification, which this converter follows. Release 1.1 also read yes, no, on, off and the single letters y and n as booleans[4], which is where the gap between older and newer tools comes from.

What to do when the converter shows a YAML error message

The message appears under the input box and usually points at one of four things:

  1. A tab in the indentation

    Indentation in YAML is built from spaces. Set your editor to insert spaces instead of tabs and redo the indentation across the file.
  2. A duplicate key

    Two entries with the same name in one block stop the conversion. The message gives the line and column of the second one, so keep the entry that should apply.
  3. An anchor pointing at its own block

    An alias referring to the data it sits inside is valid YAML, and in JSON it is written by giving the value directly. Put the value in place of the alias.
  4. A tag outside the schema

    The converter reads data only, so tags that would run programming-language code end with an invalid YAML message. Remove the tag and leave the plain value.

Convert other files to JSON

Sources

  1. YAML Ain't Markup Language (YAML™) version 1.2.2 — yaml.org
  2. RFC 8259: The JavaScript Object Notation (JSON) Data Interchange Format — IETF
  3. Managing Workloads — organizing resource configurations — Kubernetes
  4. YAML 1.1: Boolean Language-Independent Type — yaml.org
  5. OpenAPI Specification v3.1.0 — OpenAPI Initiative

Every figure in the tables was computed from the unit definitions and checked arithmetically before publication. Historical values and the names of local units come from the sources listed above.

Content last reviewed: · written and checked by the Arteon team

Frequently asked questions about converting YAML to JSON

Is every JSON file also a YAML file?

Yes. Release 1.2 of the YAML specification aimed to make the format a strict superset of JSON, so a valid JSON file is a valid YAML file too. Paste it into the left box of this converter and you get the same data back, indented with two spaces.

Why does the value yes come out as text?

The converter follows the core schema from release 1.2, where only true, True, TRUE, false, False and FALSE are booleans. Release 1.1 also covered yes, no, on, off and the letters y and n, and some older tools still work by those rules. To get a boolean in the result, write true or false in the source file.

What happens to comments from the YAML file?

Lines opened with # are skipped. RFC 8259 allows six kinds of value in JSON: object, array, string, number, boolean and null, and a comment sits outside that list. If the content of a comment needs to survive the conversion, move it into an ordinary key first, such as notes.

Can the converter handle a Kubernetes manifest holding several resources?

Yes. The Kubernetes documentation describes grouping several resources in one file separated by a line of three dashes, and the converter reads such a file whole. Every document goes into one shared JSON array, in file order. An empty document after a closing separator is skipped.

Can I use this converter on an OpenAPI or Swagger file?

Yes. The OpenAPI 3.1 specification states that the document is a JSON object which may be written in JSON or YAML, and it recommends YAML 1.2 precisely so the round trip stays faithful[5]. The result from this converter loads anywhere a tool expects an OpenAPI file in JSON, and the JSON to YAML converter covers the way back.

Does the file data reach a server?

The code that reads the file and builds the result runs on your device. The content stays in browser memory until you close the tab, and the access keys and passwords written in the configuration stay on your computer with it.

How do I convert YAML to JSON in a script or on the command line?

In Python the yaml and json modules do it: yaml.safe_load reads the file and json.dumps writes the result. In Node.js the same work is done by the js-yaml library and the JSON.stringify method. On the command line the shortest route is the yq program, which reads YAML and writes JSON in a single command.

Arteon free tool screenshot: Free YAML to JSON converter

Help us improve our tools

Have an idea, found a bug, or want to suggest a feature? Drop us a message.

Explore other useful tools