More
More
CSV to JSON Converter
Paste CSV with a header row and get a JSON array with one object per row. The delimiter is detected for you.
Free tools that run in your browser. Nothing you type, open or create is uploaded to NerdBible or anyone else.
Converted in your browser with js-yaml (MIT licence). YAML comments, anchors and custom tags have no JSON equivalent, so comments are dropped and anchors are written out in full. A YAML file with several documents separated by --- becomes a JSON array.
The rules: a key starting with @ is an attribute, the key #text holds an element's text next to attributes or children, and an array becomes the same element repeated. When there is more than one top-level key, the XML is wrapped in a root element. Comments, processing instructions and the DOCTYPE are skipped when reading XML, and entities other than the five standard ones are not expanded.
Nested objects are flattened into dot keys (address.zip) and arrays into numbered keys (tags.0, tags.1), and the reverse when converting back. Columns appear in the order they are first seen. CSV follows RFC 4180: fields with the delimiter, a quote or a line break are wrapped in double quotes. TSV is the same with a tab between fields.
TOON (Token-Oriented Object Notation) is a compact way to write JSON for large language model prompts: objects use indentation instead of braces, and a list of objects that share the same keys is written once as a header, such as hikes[3]{id,name,km,sunny}:, followed by one row per item. This converter follows the public TOON specification for objects, inline lists, tabular arrays, list items, quoting and the comma, tab and pipe delimiters.
How to use it
- Pick the format: YAML, XML, CSV, TSV or TOON. Then pick the direction, such as JSON to YAML or TOON to JSON.
- Paste your data. The result updates as you type, and an error shows its line and column.
- Set the options: indent and key order for YAML, the declaration and value types for XML, the delimiter, header row and quoting for CSV and TSV, or the delimiter and indent for TOON.
- Copy or download the result, or press Swap to convert it back.
Questions
Does the CSV need a header row?
It works best with one, because the headers become the JSON keys. Without a header, untick Header row and each row becomes an array.
Will leading zeros in codes be kept?
Yes. A value such as 01234 is not read as a number, so it stays text. Untick Read numbers and true or false if you want every value kept as a string.
Can it read semicolon or tab separated files?
Yes. Detect picks the delimiter automatically, or you can choose comma, semicolon, tab or pipe.
About this tool
From rows to objects
Each row of the CSV becomes one JSON object, and the header row supplies the keys. Paste data straight from a spreadsheet or open the text of a .csv file.
- Delimiter detection. Comma, semicolon, tab and pipe separated data are recognised, or you can pick the delimiter yourself.
- Proper quoting. Quoted fields can contain commas, doubled quotes and even line breaks, following the usual CSV rules.
- Typed values. With the option on, 42 becomes a number and true or false become booleans instead of text. Values with a leading zero, such as 007, and numbers longer than 15 digits stay as text, so codes and long IDs are not mangled. Turn the option off to keep every value as a string.
- Nesting. Columns named with dots, such as address.zip, become nested objects. Turn the option off to keep flat keys.
- No header row? Untick Header row and each row becomes an array of values.
Common uses
Seeding a database or an API from a spreadsheet, building test fixtures, or loading a list into a JavaScript app. Copy the JSON or download it as a file; nothing leaves your browser.
Related tools
- CSV ViewerOpen a CSV as a sortable table.
- JSON Formatter & ValidatorPretty-print, minify and validate JSON.
- JSON to TypeScriptTypeScript types from a JSON sample.
- Sort & Dedupe LinesSort, reverse, shuffle and remove duplicate lines.