Export and download CSV with Papa Parse

How Papa Parse turns JavaScript data into CSV or TSV, what unparse changes, and the steps and checks needed to deliver a usable file download.

Papa Parse is best known as a CSV parser for JavaScript, but it also works in the other direction: its unparse function turns arrays and objects into delimited text. This review covers what that conversion changes, how to turn the result into a downloadable file, and the limits worth checking before you rely on it for sharing data.

Short verdict: is Papa Parse a good fit for CSV export?

For browser or Node.js code that already holds tabular data in memory, Papa Parse is a reasonable choice for producing CSV or TSV text. The main benefit is correct quoting and escaping: fields containing delimiters, quote characters or line breaks are wrapped and escaped so the structure survives. The decisive tradeoff is scope. Papa Parse produces a string; it does not save files, set encodings for a target spreadsheet program, or check how the file will be interpreted after download. Those steps stay with your own code and testing.

Plain text or a different format may be the better choice when the data is not tabular, when nested structures need to be preserved (JSON keeps them; CSV flattens or stringifies them), or when recipients need typed values such as dates and numbers to survive intact, since CSV stores everything as text.

What Papa.unparse actually changes

Unparse is a serialization step, not a visual or character-level transformation. It does not reverse, mirror or restyle characters. It takes values and joins them into rows and columns using a delimiter and line terminator, adding quote characters where needed. The underlying characters of each value are kept, apart from the escaping that the CSV format requires, such as doubling a quote character inside a quoted field.

Papa.unparse accepts three input shapes:

  • An array of arrays, where each inner array becomes one row.
  • An array of objects, where object keys become the header row and values fill the rows beneath.
  • An object with fields and data properties, where fields supplies the header and data supplies the rows.

With an array of objects, the header is taken from the keys of the first object. If later objects have keys the first one lacks, those values can be left out of the output. Passing an explicit columns option fixes the column list and order, which is safer when records are not uniform.

Configuration options that affect the output

Option | What it controls
delimiter | The field separator; a comma by default, a tab character for TSV
newline | The line terminator between rows; carriage return plus line feed by default
quotes | Whether to quote every field, only fields that need it, or selected columns
quoteChar and escapeChar | The characters used to wrap fields and escape quotes inside them
header | Whether to write the header row when converting objects
columns | An explicit list and order of keys to export
skipEmptyLines | Whether empty rows are dropped from the output
escapeFormulae | Whether fields that start with characters spreadsheets treat as formulas are prefixed so they are read as text

Option names and defaults can change between releases, so confirm them against the documentation for the version you install.

Turning the CSV string into a download

Because Papa Parse stops at a string, a browser download needs a few standard web APIs: wrap the text in a Blob, create an object URL for it, and trigger a link that has a download attribute. The following sketch shows that pattern.

const rows = [
  { name: "Ada", note: "Says \"hello\", often" },
  { name: "Lin", note: "Line one\nLine two" }
];

const csv = Papa.unparse(rows, {
  columns: ["name", "note"],
  escapeFormulae: true
});

const blob = new Blob([csv], { type: "text/csv;charset=utf-8;" });
const url = URL.createObjectURL(blob);

const link = document.createElement("a");
link.href = url;
link.download = "export.csv";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
URL.revokeObjectURL(url);

In that example, the note containing a comma and quote marks and the note containing a line break will both be wrapped in quotes, with the inner quote marks doubled, so each record still occupies a single logical row. For a TSV file, set the delimiter to a tab character, change the file name extension, and use a matching type such as text/tab-separated-values.

In Node.js there is no download link; the same string is typically written to a file or sent as an HTTP response with an appropriate content type and a content-disposition header that names the file.

Will the file stay readable and usable after download?

A correctly structured CSV can still be misread by the program that opens it. The following points are where problems most often arise, and each should be checked in the specific destinations your readers use rather than assumed from one successful test.

  • Character encoding: the Blob above holds UTF-8 text. Some spreadsheet software has been reported to misread UTF-8 files without a byte order mark, which can garble accented letters and non-Latin scripts. Prepending a byte order mark to the string is a common workaround, but it can add an unwanted leading character for tools that do not expect it.
  • Delimiter and locale: in regions where the comma is the decimal separator, spreadsheet programs may expect semicolons instead. TSV avoids some of that ambiguity but is less familiar to some recipients.
  • Value interpretation: CSV carries no types. Leading zeros, long numeric identifiers and date-like strings may be reformatted by the program that opens the file.
  • Formula injection: values that begin with characters such as the equals sign can be executed as formulas when opened in a spreadsheet. The escapeFormulae option prefixes such values so they are read as text, which changes what the recipient sees in the cell.
  • Emoji and combining characters: unparse does not split or reorder characters, so these survive serialization, but display depends on the font and software used to view the file.
const blob = new Blob(["\uFEFF" + csv], { type: "text/csv;charset=utf-8;" });

Accessibility mostly concerns the export control rather than the file. A visible, labeled button that starts the download is easier to find and announce than a link created and clicked only by script. Once opened, a CSV has no headings markup or table semantics beyond its header row, so a clear, descriptive header row matters for anyone navigating the data with assistive technology. No scoped tests of specific screen readers or spreadsheet programs were available for this review, so those behaviors should be verified directly.

Gaps in the available evidence

This review relies on Papa Parse's documented behavior and on standard browser APIs. No benchmark figures, version-specific test results or compatibility measurements for particular spreadsheet applications were supplied, so performance on very large datasets and exact rendering in named programs remain open questions. Testing a representative sample file, including non-ASCII text, embedded line breaks and values with leading zeros, in each target application is the most reliable way to confirm the export meets your needs.