// admin tools · 09
Data converter
JSON ⇄ YAML ⇄ CSV in both directions, plus TypeScript interfaces and Zod schemas inferred from a sample payload — optional keys, unions and nested types included.
// runs locally — nothing is uploaded
How it works
What it does
Paste data in one format and get it in another, live. JSON, YAML and CSV convert in any direction, and JSON (or YAML or CSV, once parsed) can be turned into TypeScript interfaces or a Zod schema. Conversion happens entirely in this page — no upload, no server.
How to use it
- Pick
fromandto. The sample changes to match the source format until you edit it. - Paste, open or drop a file.
.json,.yaml,.yml,.csvand.tsvswitch the source format for you. - Tune the options for that pair, then copy or download the result.
⇄ swapfeeds the output back in and flips direction.
CSV, done properly
The CSV parser follows RFC 4180: fields with commas, quotes or line breaks are wrapped in double quotes, and a quote inside is doubled ("Mia ""MJ"" Jones"). Line endings can be CRLF, LF or CR. The delimiter can be comma, semicolon (common in European Excel exports), tab or pipe, or detected automatically from the first rows.
- flatten
- JSON → CSV turns nested objects into dot keys:
{"address":{"city":"Brisbane"}}becomes a columnaddress.city; arrays becometags.0,tags.1. - unflatten
- CSV → JSON reverses it, so a JSON → CSV → JSON round trip gives back the same shape.
- infer types
- Plain numbers,
true/falseand empty cells become numbers, booleans andnull. Values with leading zeros such as postcodes or007, and integers too large to hold exactly, stay strings.
How the types are inferred
Every value in the sample is visited, and array elements are merged into one shape. A key that appears in only some elements becomes optional (note?: string). A key seen with different types becomes a union (string | number), and null is kept as | null. Nested objects get their own interface, named in PascalCase from the key — singularised for arrays, so items gives Item[]. Identical shapes are declared once and reused. Empty arrays become unknown[], since there is nothing to infer from. Zod output mirrors this with .optional(), .nullable(), z.union and .int() where every number was whole.
FAQ
Which YAML features are supported?
YAML parsing and output use js-yaml 4.1.0, so anchors, aliases, merge keys, block and flow styles and multi-document files (returned as an array) all work. Timestamps become ISO strings, because JSON has no date type. Comments can't survive a round trip — JSON has nowhere to keep them.
Why are my CSV numbers still strings?
Either infer types is off, or the value isn't a plain number — leading zeros, thousands separators, currency symbols and spaces all keep it a string, on purpose, so nothing is silently changed.
How good are the inferred types?
They're only as good as the sample. A field that is always present in your sample will be required, even if the real API sometimes omits it. Paste several representative records, then review the output before committing it.
Is anything sent to a server?
No. The YAML library is bundled with the site, and everything else is plain JavaScript in this page. Files are read locally with FileReader.