Skip to content
moxon home

CSV Conversion

The /csv endpoint converts between CSV and JSON: parse turns CSV text into an array of objects, format does the reverse.

posthttps://api.moxon.dev/v6/csv

How it works?

The parser respects quoted fields, including escaped quotes ("") and newlines inside a quoted field. CRLF and CR line endings are normalized to LF before parsing.

Try itpost/v6/csv

Parameters

The request body must be JSON:

  • action"parse" | "format"required

    Action to perform: parse or format

  • csvstringconditional

    CSV text to convert (required for parse)

  • jsonjsonconditional

    Array of objects to convert (required for format)

  • delimiterstringoptional

    Field separator, a single character. Default: ,

  • headersbooleanoptional

    parse only: use the first row as object keys. Default: true

Available Actions

ActionDescription
parseConverts CSV text into an array of objects
formatConverts an array of objects into CSV text

Response Fields

parse action:

  • actionstring

    parse

  • rowsobject[]

    Array of parsed row objects

  • countnumber

    Number of rows returned

format action:

  • actionstring

    format

  • csvstring

    The generated CSV text

  • countnumber

    Number of rows converted

Code Examples

Error Handling

If parameters are missing or invalid, the API will return an error:

  • 400Please provide an action (?action=parse|format)The action parameter is missing
  • 400Please provide a valid action (?action=parse|format)The action value is not parse or format
  • 400Delimiter must be a single characterThe delimiter is not exactly one character
  • 400Please provide CSV data (?csv={data})The csv parameter is missing for parse
  • 400CSV cannot exceed 50000 charactersThe csv text exceeds the maximum length
  • 400CSV cannot exceed 1000 rowsThe parsed data has more rows than the limit
  • 400Please provide a JSON array (?json=[...])The json parameter is missing, not an array, or empty for format
  • 400JSON cannot exceed 1000 rowsThe json array has more rows than the limit