Skip to content
BCBinary Code Translator
Menu

Data utility

JSON to CSV Converter

Convert arrays of JSON objects to RFC 4180-style CSV and parse CSV back into JSON records, with explicit handling for headers, empty cells, nested values, embedded line breaks and spreadsheet formula injection.

Records are processed locally. Export protection is enabled by default for cells that could be interpreted as spreadsheet formulas.

How to convert JSON and CSV

Select a direction and paste the source. JSON to CSV expects an array whose items are objects. CSV to JSON treats the first row as headers and returns string or null cell values instead of guessing numbers and dates. Configure the few decisions that cannot be inferred safely.

  1. For JSON to CSV, provide an array of objects. Headers are collected in first-seen order across all records.
  2. Choose whether nested arrays and objects should be serialized as compact JSON text or rejected as non-tabular data.
  3. Keep spreadsheet formula protection enabled when the CSV may be opened in Excel, LibreOffice or another spreadsheet application.
  4. For CSV to JSON, choose whether an empty cell becomes null or an empty string, then verify row lengths and quoted multiline fields.

Examples and expected behavior

Input Output Notes
[{"name":"Jane","age":30}] name,age Jane,30 Scalar object fields become columns and rows use CRLF separators.
[{"name":"Doe, Jane","note":"She said \"hi\""}] name,note "Doe, Jane","She said ""hi""" Commas and quotation marks are enclosed and escaped according to CSV rules.
name,note Jane,"Line 1 Line 2" [{"name":"Jane","note":"Line 1\r\nLine 2"}] A quoted field may contain an actual line break without ending the record.
name,value 泉, [{"name":"泉","value":null}] With the null policy, an empty cell becomes JSON null while Unicode is preserved.
[{"cell":"=2+3"}] cell '=2+3 Formula-like cells receive a leading apostrophe when protection is enabled.
[{"meta":{"ok":true}}] meta "{""ok"":true}" The stringify policy stores a nested value as JSON text inside one CSV cell.

JSON input shape and header selection

JSON to CSV requires one top-level array, and every array item must be a non-null object rather than a primitive or another array. The converter scans records in order and collects every property name the first time it appears. This produces a stable header order based on the source instead of alphabetically rearranging columns. Missing properties become empty cells.

CSV is tabular, while JSON objects can vary by row. A wide or inconsistent object set may therefore create many mostly empty columns. Before export, consider normalizing records to a documented schema. Property names are converted to header text and receive the same spreadsheet-injection protection as data cells. Duplicate headers are rejected during CSV import because they cannot map unambiguously to object properties.

  • Top level must be an array of objects.
  • Headers are the union of property names in first-seen order.
  • Undefined is not valid JSON; null becomes an empty CSV cell.

RFC 4180-style quoting and line endings

The writer separates fields with commas and records with CRLF. A field is enclosed in double quotes when it contains a comma, quotation mark, carriage return, line feed or leading or trailing whitespace. Inside a quoted field, each quotation mark is doubled. These rules follow the common RFC 4180 model used by many spreadsheet and database tools.

The parser accepts CRLF, LF or CR record endings and preserves line breaks inside quoted fields. It rejects an unclosed quote, a quote that appears after unquoted text and characters placed between a closing quote and the next delimiter or record ending. Strict behavior catches damaged exports instead of guessing how to split rows. CSV dialects using semicolons, tabs or custom escape characters are outside this page’s scope.

  • A quoted newline is data, not a row boundary.
  • Two adjacent quotes inside a quoted field represent one literal quote.
  • The export always uses commas and CRLF for predictable output.

Empty cells, types and nested-value policy

CSV has no universal null marker or type system. During import, this tool keeps every non-empty cell as a string and lets you choose whether an empty cell becomes null or an empty string. It does not guess that 00123 is a number, that true is a boolean or that a date-looking cell is a timestamp. Avoiding inference protects leading zeros and reduces locale-dependent surprises.

During export, strings, finite JSON numbers and booleans become text. Null and missing properties become empty cells. Arrays and objects are either serialized as compact JSON within one cell or rejected, depending on the selected nested-value strategy. Stringifying is convenient for transport but does not create a normalized relational table; consumers must know that the cell itself contains JSON.

  • Choose null when absence and empty text should differ.
  • Choose empty string for a simpler all-string record model.
  • Reject nested values when downstream software expects a strictly flat schema.

Spreadsheet formula injection

Spreadsheet applications may interpret cells beginning with =, +, -, @, tab or carriage return as formulas or commands when a CSV file is opened. If untrusted data reaches such a cell, the spreadsheet can calculate unexpected expressions, create links or trigger application-specific behavior. The exporter therefore prefixes formula-like text with an apostrophe by default.

The apostrophe changes the exported cell value, so protection is a policy tradeoff rather than a transparent encoding rule. Keep it enabled for files intended for manual spreadsheet use. Disable it only when the receiving system treats CSV strictly as data and exact leading characters are required. Even with this option, apply organizational controls for untrusted files and keep spreadsheet software updated.

  • Protection applies to headers and data cells.
  • Leading whitespace is considered before checking the first dangerous character.
  • CSV quoting alone does not stop formula interpretation.

Typical uses and data review

Common uses include exporting small API datasets for analysts, converting spreadsheet samples into JSON fixtures, preparing contact or inventory records, and inspecting vendor CSV files during integration work. The tool is most reliable when the dataset is modest, flat and governed by a known column schema.

After conversion, review headers, row counts, empty values, embedded newlines and any nested JSON cells. For regulated or business-critical imports, validate allowed columns and data types in the destination system rather than relying on this structural conversion. Large datasets are better handled by streaming tools that can enforce size limits and report errors without loading the entire file into browser memory.

  • Create JSON fixtures from a quoted CSV sample.
  • Export API records for a one-time spreadsheet review.
  • Verify how commas and line breaks are escaped.
  • Check formula-injection handling before distributing a file.

Errors and interoperability boundaries

Import errors identify malformed quoting, missing or duplicate headers, and rows whose field count differs from the header count. Export errors identify invalid JSON, a non-array top level, non-object rows or nested values when rejection is selected. The converter does not repair ragged rows, merge duplicate columns or infer a delimiter from regional settings.

CSV is not one perfectly uniform standard. Some applications use semicolon delimiters, UTF-16, a byte-order mark, locale-specific decimal commas or nonstandard quote rules. This page emits UTF-8 text without adding a BOM and follows a comma-separated RFC 4180-style dialect. Test the result with the exact destination, especially when importing into legacy software.

  • The parser does not support comments or multiple header sections.
  • A successful parse does not validate email addresses, numbers or dates.
  • Browser memory defines the practical file size limit.

How this differs from JSON and YAML tools

The JSON formatter preserves nested structure and changes only JSON presentation. The JSON to YAML converter also preserves nested structure but changes syntax. CSV requires a table, so objects must be projected onto shared headers and nested values need an explicit policy. This makes CSV suitable for rows and columns but not a general replacement for JSON.

Use a database import tool when you need schema mapping, transactions or millions of rows. Use a spreadsheet library when you need native XLSX types, formulas and worksheets. Use this converter for transparent, inspectable text transformations and small integration samples. Keeping type inference disabled makes the result less magical and easier to audit.

Frequently asked questions

Does the CSV output follow RFC 4180?

It follows the common RFC 4180 style: comma delimiters, CRLF record endings, double-quoted fields when needed and doubled quotation marks inside quoted fields. CSV implementations vary, so test the output with the exact destination application.

Why are imported numbers returned as strings?

CSV does not carry reliable type metadata. Automatic conversion can destroy leading zeros, change large identifiers or misread locale-specific dates. This tool preserves non-empty cells as strings and lets the receiving application apply an explicit schema.

How are nested objects and arrays handled?

You can serialize them as compact JSON text inside a cell or reject them. Stringifying preserves the nested value in one column but does not flatten it into relational columns. The consumer must know to parse that cell as JSON.

What is spreadsheet formula injection protection?

Cells beginning with characters such as =, +, -, @, tab or carriage return may be interpreted as formulas by spreadsheet software. The default protection prefixes such cells with an apostrophe. Quoting the field alone is not sufficient.

Can the parser read multiline CSV fields?

Yes. A line break inside a properly quoted field is preserved as part of the value. A line break outside quotes ends the record. Unclosed quotes or characters after a closing quote are reported as errors.

Is this suitable for very large CSV files?

The entire input and output are held in browser memory, so it is intended for small and medium conversions. Use a streaming command-line or server-side pipeline with size limits, schema validation and resumable error reporting for large datasets.

Related Developer Tools

View all tools

Cookie Preferences

Manage your cookie preferences. Necessary cookies cannot be disabled.

Necessary

Required

Required for language selection, privacy choices, and basic site functionality.

Cookies: NEXT_LOCALE

Analytics

Optional analytics cookies help us understand traffic and improve the website.

Cookies: _ga, _gid, _gat, _clck, _clsk

Advertising

Optional advertising cookies may be used to show relevant ads and measure performance.

Cookies: __gads, _gcl_au, IDE