Fast and highly configurable JSON to CSV converter.
- Fast and lightweight
- Support for standard JSON as well as NDJSON
- Scalable to infinitely large datasets (using stream processing)
- Advanced data selection (automatic field discovery, underscore-like selectors, custom data getters, default values for missing fields, ...)
- Support for custom input data transformation
- Support for custom csv cell formatting.
- Highly customizable (supporting custom quotation marks, delimiters, eol values, etc.)
- Automatic escaping (preserving new lines, quotes, etc.)
- Optional headers
- Unicode encoding support
- Pretty printing in table format to stdout
There are multiple flavours of json2csv:
- The Plainjs package includes:
- Parser: Pure Javascript synchronous parser. High-performant and runs both node.js and the browser. It´s the fastest but loads both the JSON and the resulting CSV in memory, and block the event loop while processing. Not recommended unless the JSON data is small.
- Stream Parser: Pure Javascript stream parser. High-performant and runs both node.js and the browser. It keeps a consistent memory footprint and doesn't block the event loop. It's the base of all other parsers. Recommended to build your own parser.
- The Node packages includes:
- Node Transform: Wraps the
Stream Parser
in a Node.js Transform Stream. Recommended for Node.js users using stream. - Node Async Parser: Wraps the
Node Transform
to offer a friendly promise-based API similar to the synchronousParser
. Recommended for Node.js users that want a higher abstraction level.
- Node Transform: Wraps the
- The WHATWG package includes:
- WHATWG Transform Stream: Wraps the
Stream Parser
in a WHATWG Transform Stream. Recommended for browser users using web streams. - WHATWG Async Parser: Wraps the
WHATWG Transform Stream
to offer a friendly promise-based API similar to the synchronousParser
. Recommended for browser users that want a higher abstraction level.
- WHATWG Transform Stream: Wraps the
- The CLI package includes:
- CLI: Makes the node.js interfaces accesible through the command line. Recommended from CLI (sh/bash/zsh/...) users and CLI scripts.
And a couple of libraries that enable additional configurations:
- The Transforms package includes the built-in
transforms
for json2csv (unwind and flatten) allowing the using to transform data before is parsed (See docs). - The Formatters package includes the built-in
formatters
for json2csv (one for each data type, an excel-specific one, etc.). Formatters convert JSON data types into CSV-compatible strings (See docs).
See https://juanjodiaz.github.io/json2csv.
See LICENSE.md.