# YAML, TOML and JSON converter

Convert between JSON, YAML and TOML, or validate and pretty-print a document, with the line and column of every error.

https://codeknife.dev/en/yaml-toml-json-converter/

## What it does

Converts a document between JSON, YAML and TOML in either direction, or validates and pretty-prints one when both formats are the same. Every syntax error comes with the line and column where it was found.

## How to use it

1. Paste a document or drop a file.
2. Choose its format under **From** and the format you want under **To**. The same format on both sides validates and pretty-prints.
3. Pick the indentation, then copy or download the result, or use **Use output as input** to turn it around.

## Examples

`name: codeknife` and `ports: [80, 443]` in YAML become `{"name": "codeknife", "ports": [80, 443]}` in JSON, and `name = "codeknife"` and `ports = [ 80, 443 ]` in TOML.

## Good to know

- YAML is read as version 1.2: only `true` and `false` are booleans, so `yes` and `on` stay text. A document with several `---` parts, a repeated key or too many aliases is refused.
- TOML needs a table at the top level and has no null. Converting a list or a null to TOML gives an error that names the path.
- Dates in TOML stay dates when you pretty-print TOML, and become text when you convert to JSON or YAML.
- Comments are not kept when converting, because JSON has none and the parsed data does not carry them.

## How do I validate or pretty-print instead of converting?

Pick the same format for From and To. The document is read strictly, so any mistake is reported with its line and column, and a valid one is written back with consistent indentation.

## Frequently asked questions

### Why do yes, no and on stay text in YAML?

This tool reads YAML 1.2, where only true and false are booleans. yes, no, on and off stay plain text, unlike in some older YAML 1.1 parsers.

### Why can't every JSON document become TOML?

TOML has a table at its top level and no null. A top-level list, or a null anywhere, is refused with a message that names the path instead of being dropped silently.

### Does this tool send my data anywhere?

No. Everything happens in your browser. What you type is never sent to our servers.