Toolvito

Works on this device

YAML & TOML Editor

Paste a YAML, TOML or JSON text to see its structure, to compare it with a second text, or to write it in another format. You can also check and format TOML. Your text is read in this browser and is not uploaded.

Your text

Shows the data as an outline, one line for each key and value with its type, and as a table of paths.

Type or paste the text. It is read on this device and is not uploaded.

More options

Your values are worked out in this browser. They are not sent to a server.

Your result will show here

Type or paste a text, or choose Try an example.

How to use this tool

  1. Choose what you want to do: view, compare, convert, list the paths of an OpenAPI file, or format or check TOML.
  2. Type or paste the text in the box, or choose Or open a file from your device. Say if the text is YAML, TOML or JSON. The result updates as you type.
  3. To compare, paste the second text in the second box. The two texts can be in different formats.
  4. To convert, choose the format to write, and 2 or 4 spaces for one level of YAML or JSON.
  5. For YAML, More options has three choices: apply merge keys (<<), allow custom tags such as !Ref, and accept lines without indentation inside brackets and quotes. Each one is listed in the notes when it changes how the text is read.
  6. Choose Copy text or Download file to keep the result. Download CSV saves the counts and every row of the tables.

What each option does

  • View a YAML, TOML or JSON file as a structure shows an outline with one line for each key and value and its type, and a table of every value with its path.
  • Compare two documents by meaning lists the paths that were added, removed or changed. The order of keys, spacing, quotes and comments do not count.
  • Convert between YAML, TOML and JSON reads the data and writes it again in the other format. A table lists everything that was lost or changed. You can also write a text again in its own format, in a standard form.
  • List the paths of an OpenAPI or Swagger file shows every path with its operations, such as GET /items.
  • Format TOML (keeps comments) makes the spacing of a TOML text even and keeps every comment and value.
  • Check if TOML is valid checks the text against TOML 1.0.0 and shows the line and column of the first mistake.

How to read the outline and the table

  • A line with a colon is a mapping or a list: service: mapping, 4 keys. The lines inside it are indented by 2 spaces.
  • A line with an equals sign is one value with its type in brackets: port = 8080 (integer). Text is shown in double quotes, so spaces and line breaks can be seen. Items of a list are named [0], [1] and so on.
  • In the table, a path such as /service/port is a JSON Pointer: the key port inside the key service. In a key, ~1 stands for / and ~0 stands for ~.
  • The types are: text, integer, float, true or false, null, list and mapping, and the four date and time types of TOML.

How two documents are compared

  • Two mappings are the same when they have the same keys with the same values. The order of the keys does not count.
  • Two lists are compared item by item, by position. An item added at the start of a list shows as a change of every item after it.
  • A whole number and a float are different values: 1 is not 1.0. A number is not text: 1 is not "1". Two floats are the same when they are the same number: 2.5 and 2.50.
  • added means that the path is only in the second text. removed means that it is only in the first text. changed shows the value in both.
  • YAML aliases are written out before the comparison. Comments are not compared.

What is lost when you convert

The three formats cannot all hold the same things. The tool lists every loss with its place. After writing, it reads its own result and compares it with your data. If the two differ in any other way, it shows no result.

What each format cannot hold
When you write What happens
Any format Comments are lost, because the text is written again from the data. Use a formatter to keep comments.
JSON A date or time of TOML becomes a string. Infinity and "not a number" become null. Several YAML documents become one list.
YAML A date or time of TOML becomes text in quotes. Anchors and aliases are written out. Text such as yes, no, 12:30 or 2001-12-14 gets quotes, so that older YAML readers also take it as text.
TOML A key whose value is null is left out, because TOML has no null. In each table the keys with simple values are written before its tables. Data with null inside a list, with a whole number outside 64 bits, or with a list or a single value at the top cannot be written as TOML.
From YAML A key that is not text (such as 1 or true) becomes text. With Apply YAML merge keys, a key << adds the keys of the mapping it points to.

TOML

TOML is read and written by the rules of TOML 1.0.0: tables, inline tables, arrays of tables, the four kinds of strings, whole numbers in base 10, 16, 8 and 2, floats with inf and nan, and the four kinds of dates and times. A key or a table that is written twice is a mistake, and the tool gives the place of both.

The TOML formatter works on your text. It removes spaces at the start of lines, puts one space on each side of each equals sign, tidies table headers such as [ a . b ] to [a.b], and removes spaces at line ends. It does not change values, comments or the order of lines, and it does not touch the inside of arrays or text that goes over several lines. After formatting it reads the result and compares the data and the comments with your text.

OpenAPI and Swagger files

An OpenAPI or Swagger file is YAML or JSON with a key paths. The tool reads the file as plain data and lists each path with its operations: the method, the operation id, the first line of the summary and the tags. It also shows the title, the version and the number of schemas.

The tool does not check the file against the OpenAPI rules, it does not follow $ref references, and it does not draw the pages that an API viewer shows. Use the structure view to see every key of the file.

Worked example

Choose Try an example in the view option. The sample has 10 lines of YAML. The outline starts with document: mapping, 2 keys and shows port = 8080 (integer), timeout = 2.5 (float) and note = null (null). The counts are 12 values: 3 mappings, 1 list, 3 text values, 2 integers, 1 float, 1 true or false value and 1 null.

In the compare option, the example has a second text with the port 9090, one more host, no note, the keys in another order and the timeout written as 2.50. The result is 3 differences: /service/port changed from 8080 to 9090, /service/hosts/2 was added, and /limits/note was removed. 6 values are the same; the key order and 2.50 make no difference.

Converting the first sample to TOML gives two tables, [service] and [limits], and one loss: the key /limits/note is left out, because its value is null and TOML has no null.

In the option Format TOML, the example has 10 lines and 4 of them change: name = "A. Sample" becomes name = "A. Sample", [ service ] becomes [service], and port=8080 becomes port = 8080.

Limits you should know

  • A text can have up to 1,000,000 characters and data nested up to 100 levels deep. The view and the check show up to 200,000 values. YAML aliases may grow to 250,000 values; a text that grows past that is refused.
  • YAML is read by the rules of YAML 1.2 for the part that the YAML Formatter & Validator lists. Some rare parts of YAML, such as keys that start with ?, are not read; the tool then names the part and stops.
  • Converting writes the text again from the data, so comments are always lost. To keep comments, use Format TOML here or the YAML formatter.
  • Numbers keep their digits: 1.50 stays 1.50, and a long whole number is not rounded. TOML takes whole numbers from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 only.
  • A date in YAML or JSON is text for this tool. Only TOML has date and time types, so text that looks like a date does not become a TOML date.
  • In JSON, when one object has the same key twice, the last value is used and the place is listed.
  • The tool does not check a file against a schema or against the rules of a product such as Kubernetes or OpenAPI.
  • A file from an address on the web cannot be opened here. Copy the text and paste it, or save the file and open it.

Related tools