velkaro.Runs in your browser

JSON to YAML converter

Paste JSON or open a .json file to get YAML you can drop into a config file. Strings that a YAML parser would turn into something else are quoted, and the YAML is read back with both YAML 1.1 and 1.2 rules to confirm the data did not change.

Example Replace it with your own JSON.

⇄ Convert the other way
Indent

Which strings get quotes

Most strings are written plain, without quotes. A string is quoted only when a YAML parser would read the same characters as a boolean, a number, a date or null, or when they cannot be written plain at all, such as text containing : or starting with #, - or [. The test is not a fixed word list: each candidate is parsed with the YAML 1.2 core schema and with the YAML 1.1 types, and it is quoted if either one returns something other than the original string.

JSON stringWritten plain, YAML 1.2 readsWritten plain, YAML 1.1 reads
"NO", "yes", "on"the stringa boolean (bool type)
"0755"the number 755octal, 493 (int type)
"22:22"the stringbase 60, 1342
"1.10"the number 1.1the number 1.1
"2026-11-08"the stringa date (timestamp type)
"~", "null"nullnull

The country code NO for Norway is the classic case: written plain, a YAML 1.1 parser reads it as false. Clear Quote for YAML 1.1 too to quote only what YAML 1.2 needs; the round-trip line then shows which version would read different data. For the full list of values that change type, see YAML vs JSON: the type surprises.

The round-trip check

After writing the YAML, the converter parses its own output twice, once with YAML 1.2 rules and once with YAML 1.1 rules, and compares the result with your JSON value by value. Numbers are compared by exact decimal value, so 1.10 and 1.1 count as the same number but 12345678901234567890 and 12345678901234567000 do not. The report shows one line per version; a failure names the version that would see different data.

Numbers, nulls, lists and long text

  • Numbers keep the digits from the JSON. 12345678901234567890 is not rounded, and 1.10 keeps its trailing zero.
  • null stays null; empty objects and arrays are written {} and [].
  • Key order is kept as it is in the JSON.
  • Long strings stay on one line, so a later diff of the YAML shows real changes rather than re-wrapped lines.
  • A string with line breaks becomes a literal block. | keeps one final line break, |- means there is none, and |+ keeps several, following the block chomping indicator. All six block forms, tested.

One document per array item

With One document per array item on, a top-level JSON array is written as separate YAML documents divided by ---. Kubernetes, for example, lets you group several resources in one file separated by ---, so an array of manifests becomes one file in that layout.

Real files: Kubernetes and GitHub Actions

Kubernetes: a JSON object as a manifest

kubectl can print an object as YAML itself (-o yaml is in its output options), so this converter is for JSON you already have: an API response, a script’s output, a template. Objects read back from a cluster also carry fields the server fills in, such as status and metadata.uid; remove them before you commit the file. Values keep their type, which matters for ConfigMaps: their data field is designed to contain UTF-8 strings.

{
  "apiVersion": "v1",
  "kind": "ConfigMap",
  "metadata": { "name": "flags" },
  "data": { "DEBUG": "no", "REGION": "NO", "RETRIES": "3", "START": "8:30" }
}
apiVersion: v1
kind: ConfigMap
metadata:
  name: flags
data:
  DEBUG: "no"
  REGION: "NO"
  RETRIES: "3"
  START: "8:30"

Written plain, no and NO would be booleans and 8:30 the base-60 number 510 to a YAML 1.1 parser such as PyYAML, and 3 a number to any parser. With Quote for YAML 1.1 too turned off, the round-trip line shows that a YAML 1.1 parser would read different data.

GitHub Actions workflows

A workflow’s on: key is written "on":, because a YAML 1.1 parser reads a plain on as true. Quoted, it is the text on for both YAML 1.1 and 1.2.

{
  "name": "CI",
  "on": { "push": { "branches": ["main"] } },
  "jobs": { "test": { "runs-on": "ubuntu-latest", "steps": [{ "uses": "actions/checkout@v4" }, { "run": "npm test" }] } }
}
name: CI
"on":
  push:
    branches:
      - main
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm test

Nothing leaves the browser

The JSON is parsed and the YAML written in this tab with the open-source yaml library, loaded from velkaro.cc. Nothing is uploaded or stored. Download saves a .yaml file, and YAML → JSON sends the result to the YAML to JSON converter. If the JSON has a syntax error, the message gives the line and column, such as a trailing comma before ].

Questions

Can I get 4-space indentation?

Yes. Choose 4 spaces under Indent. List items are indented under their key in both settings.

What happens to a JSON file with duplicate keys?

It is read the way JSON.parse reads it: the last value for the key wins, and the YAML has the key once. YAML itself does not allow a key twice, so the converter cannot write both.