Skip to content
LeedyBox
Support

Converting Between JSON, CSV and YAML

JSON, CSV and YAML can often hold the same data, but they do not map one to one. This guide explains what each format is good at, which details can change during a conversion, and how to check the result.

What Each Format Is Good At

JSON is the common format for web APIs and configuration read by programs. It has a small, clear set of types: objects, arrays, strings, numbers, booleans and null. Its strict syntax makes it easy for software to parse, but it has no comments.

CSV is a table: one row per line, one value per column. Spreadsheets, databases and reporting tools import it easily, and it is compact for large, flat data sets. It has no standard way to describe data types or nested structures.

YAML is designed to be written and read by people. It is popular for configuration files because it allows comments, uses indentation instead of brackets, and can describe the same structures as JSON. The flexible syntax also means that small indentation or quoting mistakes can change the meaning.

Feature JSON CSV YAML
Nested objects and arrays Yes No (flat table) Yes
Data types String, number, boolean, null Text only Inferred from the value
Comments No No Yes
Typical use APIs, app data Spreadsheets, imports Configuration files

Nesting Is Flattened in CSV

A CSV file has rows and columns only, so nested data has to be reshaped. There are two common approaches. The first flattens the structure into column names such as address.city and address.zip. The second keeps the nested part as a JSON string inside a single cell. The LeedyBox Data Converter offers both options.

Both approaches have trade-offs. Flattened columns are easy to read in a spreadsheet, but arrays of different lengths produce many sparse columns. JSON strings inside cells keep the structure but are harder to edit by hand. If you convert back to JSON later, check that the structure matches what you started with.

Types Become Text in CSV

CSV stores every value as text. The number 42, the string "42" and the boolean true all look the same in a cell. When a CSV file is read back, a program has to guess or be told which columns are numbers or dates. The LeedyBox converter reads CSV values as text, so numbers from a CSV file appear as strings in JSON unless you change them.

Spreadsheet apps add their own guesses: they may remove leading zeros from postcodes or phone numbers, turn long numbers into scientific notation, or interpret values as dates. Cells starting with =, +, - or @ can be treated as formulas; the converter has an optional Excel formula protection setting for CSV output.

Comments and YAML Typing

JSON has no comments, so converting YAML to JSON drops them. Converting back does not restore them. Keep the original YAML file if the comments matter.

YAML guesses types from unquoted values. Under the older YAML 1.1 rules, used by some parsers, words such as no, yes, on and off become booleans, so a country code like NO can turn into false. Values like 2026-10-02 may become date objects, and 1e3 or 010 may be read as numbers. The LeedyBox converter reads YAML with the YAML 1.2 core schema, which keeps no and dates as text, but other tools that read your file may behave differently. Quoting values that must stay text is the safest habit.

Large Numbers in JavaScript

JavaScript stores numbers as 64-bit floating point values. Integers larger than 9,007,199,254,740,991 (253 − 1) cannot all be represented exactly, so a large ID such as 12345678901234567891 can be silently rounded when parsed. This affects any browser-based converter, including this one, which shows a notice when it detects such numbers. Database IDs and other long identifiers are safer stored as strings.

Checking the Result

A conversion that produces valid output is not necessarily correct. Before you use the result:

  • Compare the row or item count with the source.
  • Spot-check a few records, including ones with empty values, special characters, line breaks or nested data.
  • Check columns that should be numbers, booleans or dates in the target system.
  • Look for long numbers that might have been rounded.
  • Validate the output with the program that will read it, using a copy of your data first.

The Text Diff tool can help compare an original file with a round-trip conversion.

Frequently Asked Questions

Can I convert JSON to CSV and back without changes?

Only for simple, flat data, and even then numbers and booleans usually come back as text. Nested data and types depend on the options used, so compare the result with the original.

Why did my YAML value turn into true or false?

Some YAML parsers treat unquoted words like yes, no, on and off as booleans. Put the value in quotes to keep it as text.

Is my data uploaded when I convert it?

The LeedyBox Data Converter runs in your browser, so the data you paste is processed on your device.