Skip to main content

Convert CSV to JSON (and JSON to CSV)

Switch easily between tabular CSV data and JSON structure, then retrieve the converted result ready to copy or download.

  • Clipboard

Embed this widget

Customize the result, check the live preview, then copy the code.

Preview

Embed code type

Code to copy

Responsive and automatically resized by Bethemesh.

Was this tool useful?

How does this tool work?

CSV describes records and columns, while JSON can represent objects, lists and several value types. This converter connects a CSV table with headings to a JSON array of flat objects. Use it to prepare an API example, recover an application export or move data between a spreadsheet and a script. The two directions do not guarantee an identical round trip: CSV does not naturally distinguish null, a missing field and an empty string, or a number from text that merely resembles one. Those distinctions need an explicit schema outside the delimiter format.

Explicitly choose comma, semicolon or tab. The setting reads CSV in one direction and writes it in the other; this interface has neither automatic detection nor a vertical-bar option. CSV to JSON always treats the first logical record as headings and creates one object per subsequent record. Surrounding spaces are removed from headings. Blank or repeated names receive replacements so all columns survive, and extra fields beyond a short header also receive properties. This avoids overwriting cells through duplicate object-property names.

Every value read from CSV remains a JSON string. An amount written 12.50 is not inferred to be numerical, and a reference 001 retains its leading zeros. Quoted fields may contain delimiters, doubled quotation marks and several lines. An unclosed quote blocks conversion. For JSON to CSV, input must be a non-empty array of objects whose cells are strings, finite numbers, booleans or null. A single object, a list of numbers or a nested cell is not an accepted flat table.

Properties found across the objects form the exported columns. A missing property or null becomes an empty cell; booleans become the text true or false, and numbers use their JavaScript textual representation. Nested objects and arrays are rejected instead of becoming unusable text. Flatten them beforehand if you need explicit path columns. JSON output is indented and CSV fields are quoted according to the selected delimiter. File imports are limited to 5 MiB and read UTF-8. Workbook styles and metadata are not part of this text-to-table conversion.

How to use this tool

  1. Choose the direction before checking input shape

    For CSV to JSON, provide a real header record. For JSON to CSV, prepare an array of flat objects rather than the complete response wrapper from an API containing a separate results property.

  2. Set the delimiter and expected types

    Select the delimiter used by the source CSV or required in the output. Check JSON punctuation: double quotes for names, commas between elements and decimal points inside numerical literals, even on a non-English page.

  3. Inspect potentially ambiguous values

    Run conversion and review generated properties, identifiers, nulls and numbers. Copy or export in the selected format, then try the result in the receiving application before committing a substantial import.

Use cases

Prepare a tabular request payload

Convert a small CSV export into an object list for a script or API test, then check the destination's required types instead of assuming numerical conversion happened automatically during serialisation.

Open a flat JSON export as columns

Produce CSV from a list of simple objects for a tabular application. Properties missing from some records become empty cells rather than causing those rows to lose alignment with the combined column set.

Retain an identifier's leading zeros

Read a reference column from CSV as JSON strings. This preserves its original spelling rather than asking the converter to guess which digit sequences identify entities and which represent quantities.

Examples

Keep prices as JSON text

CSV to JSON with semicolons preserves references 001 and 002 as strings, just like their decimal prices. The output does not claim to supply amounts already typed for calculations. Its consumer must deliberately decide how those values should be converted.

Input

id;price
001;12.50
002;8.00

Result

[
  {
    "id": "001",
    "price": "12.50"
  },
  {
    "id": "002",
    "price": "8.00"
  }
]

Export numbers, booleans and missing values

JSON to CSV with semicolons writes 12.5 and true for A. B's null amount becomes empty, and its missing active property also becomes empty. Converting back would not recover the distinction between those two ways of representing absence.

Input

[{"id":"A","amount":12.5,"active":true},{"id":"B","amount":null}]

Result

id;amount;active
A;12.5;true
B;;

Tips and best practices

  • To retain a large JSON identifier without rounding, supply it as a quoted string. Numbers are read using JavaScript numerical precision rather than an arbitrary-size integer representation designed to preserve every digit.
  • Avoid repeated property names within one JSON object: the reader retains the last value before conversion. That differs from repeated CSV headings, which can be renamed while retaining every physical source column.
  • Do not globally change commas to points to convert amounts. That would also change JSON or CSV separators. Apply a targeted type conversion to the columns genuinely intended to hold numerical measures.

Sources and references

Frequently asked questions

Why do CSV numbers appear in quotation marks in JSON?

CSV does not supply reliable cell types. Keeping values as strings protects references with leading zeros and other intentional spellings. Your application's schema must determine which columns should subsequently become numbers rather than leaving that decision to delimiter parsing.

Can I directly convert a nested JSON object?

No. JSON to CSV here requires an array of flat objects. Flatten nested paths or extract the property containing the records first. Objects are not silently replaced by [object Object] when they cannot be represented as scalar table cells.

What happens to null in the generated CSV?

It becomes an empty cell, like a missing property or an empty string. This conversion cannot preserve that type distinction in CSV. If it matters, encode an explicit convention before export and document how the receiving application should interpret it.

Does a CSV and JSON round trip preserve all types?

No. Values read from CSV are returned as strings. Numbers, booleans and absent values exported to CSV do not automatically regain their original types. Headings may also be normalised to prevent collisions between object properties.

Recommended workflow

Discover tools that naturally fit before, after, or alongside this one.

Works well with

Convert Excel, CSV, and other spreadsheet formats directly in your browser.

Data & spreadsheetsFeaturedUse this tool

Format, minify, and validate JSON to make it easier to read or more compact.

Data & spreadsheetsFeaturedUse this tool

Use before

Next step

Format, minify, and validate JSON to make it easier to read or more compact.

Data & spreadsheetsFeaturedUse this tool
GuideBest practicesIntermediate

Build a reproducible data-preparation workflow

Put cleaning, validation, filtering, merging, comparison and conversion in a sensible order, and learn when a reusable pipeline is better than isolated tools.

29 August 20262 min