1001Ferramentas
🔄Converters

YAML to NDJSON Converter

Explains how to represent YAML lists as NDJSON (one JSON object per line) with practical examples.

Suporta lista de objetos planos (sem aninhamento).

NDJSON (newline-delimited JSON) é um objeto JSON por linha. Para um arquivo YAML do tipo lista:

- nome: Ana\n  idade: 30\n- nome: Beto\n  idade: 25

O equivalente NDJSON é:

{"nome":"Ana","idade":30}\n{"nome":"Beto","idade":25}

Use yq ou js-yaml em pipelines para esta conversão.

YAML lists rewritten one record per line

You have a YAML file holding a list of records and the next tool in the pipeline wants NDJSON: one JSON object per line, no trailing commas, no wrapping brackets. That is the shape jq, BigQuery and most log loaders expect. Paste the list into the top box and the conversion appears immediately, one line per item, ready to grab with the copy button.

The parser here is deliberately small and is not a full YAML implementation. It looks for lines starting with a dash to open a new record, and indented key: value lines to add fields to the record currently open. Values go through a light type pass: true, false, null and the tilde become literals, integers and decimals become numbers, and matching single or double quotes at the ends are stripped.

That is why the scope is a list of flat objects. A nested map does not become a nested object: the parent key ends up as an empty string and its children get promoted to the same level, which is easy to miss. Inline lists like [a, b] stay text, a comment containing a colon becomes a field, and a file that opens with a mapping instead of a dash produces nothing. For real files use yq or js-yaml. Nothing leaves your browser.

Frequently asked questions

Does it handle nested YAML?
No. Fields of a nested map get promoted into the parent record and the map key is left as an empty string. Flatten the YAML first, or use yq.
Why did my file produce no output at all?
It probably starts with a top-level mapping instead of a list. A record only opens when a line begins with a dash.
Are numbers in scientific notation converted?
No. 1e5 stays a string, because the type pass only recognises integers and decimals written with a dot.

Related Tools