How to convert CSV files to JSON or XML

CSV is a popular format for tabular data and can be used to export and convert from many sources like Excel or databases to JSON and XML. To make it easy to work with CSV, XML ValidatorBuddy can convert any CSV input to XML or JSON using a dialog that offers various options in a convenient way. To open the dialog use the Convert CSV file... command from the File Explorer menu.

Convert CSV files dialog
 

The dialog shows a preview of the first 20 lines of the CSV input. This allows to see how the data will be imported and changing any related options like the column separator updates the preview immediately.

There is also the output preview which shows how the input CSV data will be converted to XML or JSON. To generate the actual output use the "Convert" button. This will open a new document in the editor with the conversion results in XML or JSON.

 

Options for the CSV input

Column seperator

The CSV import supports three different column separators:

  • Semicolon
  • Comma
  • Tabulator

Encoding

Please select the encoding according to the CSV input. By default a standard ASCII encoding is selected.

Header line

Many CSV files contain a header line to set the column labels. If the current input comes with a header line, set this option to read the column labels from the first line. Also the import will then start from the second line.

Edit column labels

Below the header line option is a list of column labels. Use the check-box in each line to include or exclude the column in the output. In addition the label text can be edited. The output preview will show the changes to the column labels immediately.

Options for the XML or JSON output

Output format

The CSV data can be converted into XML or JSON using this option.

Conversion methods

XML ValidatorBuddy supports several methods what JSON or XML structure will be created from the imported CSV data. The following methods are available for the generated JSON:

  • A JSON object as array item for each CSV row
  • A JSON array for each CSV row
  • A JSON array for each CSV column

On creating XML output:

  • An element for each CSV row