Data Formats

YAML / JSON / TOML Converter

Convert between YAML, JSON, and TOML in any direction, and see what each conversion drops.

  • History kept on this deviceRecent results are kept in this browser's local storage until you clear them.
  • Runs in your browserProcessing happens in this page. No application server receives your input.

YAML

JSON

TOML

Converted

What each control does

  • YAML to JSON, YAML to TOML, JSON to YAML, JSON to TOML, TOML to JSON and TOML to YAML: each reads the pane it names and writes only its target pane. The button from the source format to the target format is the primary one in the run bar, and the other five sit beside it.
  • Copy copies the result of the last conversion. It is off until a conversion has produced text, and off again after you edit a pane.
  • Cancel stops a conversion running in the background. It appears only while one is running.

What each conversion keeps, loses and refuses

  • JSON โ†’ YAML: Preserved: values, structure, key order (integer-like keys move first). Lost, and stated: earlier values of a repeated key (a warning); integers beyond 2^53 rounded. Fails on: syntax; inf from a number overflow.
  • YAML โ†’ JSON: Preserved: values, structure. Lost, and stated: comments; anchors (expanded); custom tags (inert text); non-string keys (stringified); integers beyond 2^53 rounded; -0 becomes 0. Fails on: syntax; repeated keys, including keys that become the same text; alias budget; an alias with no anchor; a YAML version other than 1; a repeated %YAML directive; an explicit merge key; non-finite values; non-plain values; multiple documents.
  • JSON โ†’ TOML: Preserved: values, structure. Lost, and stated: key order within a table; float-valued integers such as 1.0; earlier values of a repeated key (a warning); integers beyond 2^53 become floats; -0 becomes 0. Fails on: syntax; null anywhere; a non-table at the top level; a lone surrogate; inf from a number overflow.
  • TOML โ†’ JSON: Preserved: values, structure. Lost, and stated: comments; datetimes become ISO-8601 strings. Fails on: syntax; repeated keys; integers beyond 2^53; inf and nan.
  • YAML โ†’ TOML, TOML โ†’ YAML: Preserved, lost and refused as the two hops above, composed: both rows' losses, and both rows' failures, at the hop that meets them.
  • every row: Fails on: input, depth, key, output and time bounds.

Limits

  • Comments are lost in every direction, YAML anchors are expanded, and YAML to TOML and TOML to YAML route through JSON, so both losses apply, including that inf and nan are refused on those routes though both formats can hold them.
  • TOML has no null, and a top-level TOML document is a table; {} into TOML gives a pane that reads as blank, so it does not convert back; a lone surrogate is refused into TOML.
  • Each pane holds one document, and a second is refused; YAML is read as YAML 1.2, so << is not applied and yes stays a string; a document that declares another YAML 1 version is read as YAML 1.2, with a notice; an explicit !!merge key is refused; two YAML keys that become the same text are refused.
  • Integers beyond 2^53 lose precision, illustrated by 12345678901234567890 โ†’ 12345678901234567000, with a notice on each run they affect, and become floats in TOML; 1.0 becomes 1; -0 becomes 0 in JSON and TOML text.
  • TOML datetimes become strings and stay strings on the way back.
  • Integer-like keys move ahead of other keys in the output.
  • A failed conversion leaves the target pane as it was.
  • State larger than 128.0 KB is not saved. The conversion still runs, and the page says so.

Bounds

  • Input bytes: 16.0 MB, or 4.0 MB for a YAML source. Larger input is refused before it is read.
  • Depth: 64 levels, counting the outermost as 1. Deeper input is refused.
  • Keys: 200000, counting an expanded alias each time it is reached. More is refused.
  • Aliases: 100. More is refused.
  • Output: 16.0 MB. A result that would be larger is refused, and nothing is cut.
  • Time: 30 seconds for a background run. A run that takes longer is stopped.
  • Allocation: a YAML source over 4.0 MB is refused, because the parser builds its whole tree in memory before any other count exists.
  • Listed paths: at most 1000 paths or repeated keys are listed, and the rest are counted.
  • The size of YAML and TOML output is estimated before it is written, so a result close to 16.0 MB can be refused though it would have fitted.
  • Documents of 1.0 KB or more run in the background and can be cancelled. Smaller ones run at once and cannot be cancelled.
  • A very large document can run out of time, a large YAML document can stop the tab on a device with little memory, and a very large result can pause the page briefly.

Example

Press YAML to JSON on a: {b: [1, 2]} to get:

{
  "a": {
    "b": [
      1,
      2
    ]
  }
}

Press YAML to TOML on the same YAML to get:

[a]
b = [ 1, 2 ]

Scope: this covers the page itself. Your browser, operating system, clipboard, downloads, extensions, and crash recovery may keep copies, and a compromised site origin would not be protected.