
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
csv-to-xml
csv-to-xml
is an easy-to-use library that quickly converts any CSV data in a string or file to its equivalent XML representation.
data.csv
Color,Maximum Speed,Age
red,120,2
blue,150,4;
index.js
import csvToXml from 'csv-to-xml';
import fs from 'fs/promises';
const csv = await fs.readFile('data.csv', {
encoding: 'utf-8',
});
const xml = csvToXml(csv, {
headerList: ['color', 'maxSpeed', 'age'],
});
console.log(xml);
<row>
<color>red</color>
<maxSpeed>120</maxSpeed>
<age>2</age>
</row>
<row>
<color>blue</color>
<maxSpeed>150</maxSpeed>
<age>4</age>
</row>
csvToXml(csv: string, options: CSVToXMLOptions): string
Takes string containing CSV data and returns string containing equivalent XML data.
CSVToXMLOptions
eol
: character to be treated as end of a line. If unspecified, EOL character will be auto-detected.
Type: string
Default: undefined
separator
: character used to separate each CSV column.
Type: string
Default: ','
rowName
: name given to XML element wrapping column XML elements.
Type: string
Default: 'row'
headerList
: List of custom header names to use for the CSV.
Type: string[]
Default: []
header
: Whether the CSV data contains a header row or not.
Type: boolean
Default: true
indentation
: Number of spaces used to indent the XML output. A string like \t
or ' '
can also be passed.
Type: number | string
Default: 4
quotes
: If a column contains the separator character, you can use a quote charactor to wrap the column content, e.g., "Coding, Beauty" won't be split into two columns during parsing.
Type: single | double | all | none | RegExp
single
: use single quotesdouble
: use double quotesall
: use single and double quotesnone
: ignore quotes - treat as part of CSVRegExp
: custom regex pattern, e.g., /[\(|\)]/
for column enclosed with (
and )
.Default: 'none'
FAQs
Easily convert any CSV string to XML data in Node.js and the browser.
The npm package csv-to-xml receives a total of 109 weekly downloads. As such, csv-to-xml popularity was classified as not popular.
We found that csv-to-xml demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.