Format Converter

Format Converter API

Development

Free JSON, CSV, and XML converter. Easily transform data formats with our intuitive online tool for developers.

Authentication

All API requests require a valid API key passed in the Authorization header as a Bearer token.

Rate Limit

120 requests per minute

Endpoints

1 endpoint available

Overview

Convert data between JSON, CSV and XML. Send the data as a string with the format it is in and the format you want back.

Conversions

  • JSON to CSV: works for an array of objects, or a single object. Column names come from the keys.
  • CSV to JSON: the first row is the header, and each later row becomes an object.
  • JSON or CSV to XML: an array becomes a <root> element with one <item> per entry. A single object is wrapped in <root><element>. Output is indented with 4 spaces.
  • XML to JSON: the root element's children become keys, and repeated tags become arrays. Attributes, comments, CDATA sections and the XML declaration are ignored.
  • XML to CSV: only works when the XML parses to an array of records, which is rare, so expect a 400 for most XML. Convert to JSON first.

Notes

  • data is limited to 500,000 characters.
  • inputFormat and outputFormat must be different.
  • Invalid input returns a 400 with a message such as "Invalid JSON format".
  • JSON output is indented with 2 spaces.

Endpoints

POST
https://opentools.ca/api/v1/tools/format-converter
Convert data between JSON, CSV and XML

Request Body

Content-Type: application/json

ParameterTypeRequiredDescription
data
string
Required
The data to convert, 1-500,000 characters
inputFormat
string
Enum: json, csv, xml
Required
Format of data
outputFormat
string
Enum: json, csv, xml
Required
Format to convert to. Must differ from inputFormat.

Response Example

{
  "success": true,
  "inputFormat": "json",
  "outputFormat": "csv",
  "output": "name,age\nJohn,30\nJane,25"
}

Error Codes

400
Bad Request - Invalid request, same input and output format, or data that cannot be parsed or converted
401
Unauthorized - Invalid or missing API key
403
Forbidden - API key is inactive or expired, or the request IP is not allowed
429
Too Many Requests - Rate limit exceeded
500
Internal Server Error

Code Examples

curl -X POST https://opentools.ca/api/v1/tools/format-converter \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "data": "[{\"name\":\"John\",\"age\":30},{\"name\":\"Jane\",\"age\":25}]",
    "inputFormat": "json",
    "outputFormat": "csv"
  }'

Ready to get started?

Create an API key to start using the Format Converter API.

Rather use it in your browser? Open the Format Converter