CSV to JSON Converter

Updated: Feb 23, 2019

CSV to JSON Converter is used to convert CSV data or file into JSON format. You can choose whether the property names are auto-generated or taken from the header row in the CSV. Property names can also be transformed using various naming strategies such as: Camel Case, Lower Case, Upper Case & Snake Case The JSON output can be indented for easier viewing. Source delimiter is automatically detected but can also be manually overriden. The JSON output varies itself according to various strategies. Check out the setting descriptions below.



Input: Paste CSV content below



Settings

JSON to CSV Converter

Convert JSON text (even nested ones) into CSV format using the delimiter of your choice. Output in tabular format is also available

View Tool
Background Information

CSV to JSON Array

  1. Paste CSV data in the input or select a CSV file from your system
  2. Configure any conversion settings such as delimiter type, whether first row is header
  3. Hit the convert button to convert your CSV into JSON

CSV

CSV is an old & very popular format for storing tabular data. It has been used in the desktop as well as mainframe. It is a simple & compact format that works really well for tabular data and so is still in use today.

JSON

JavaScript Object Notation (JSON) pronounced as "Jason" is the de facto standard for data interchange on the web these days. It is a simple format that is easier to comprehend than XML. It also has less size than XML because of no closing tags. Interacting with JSON from JavaScript is extremely seamless. JSON format was first specified by Douglas Crockford in the early 2000s

Settings Explained

  • 1. First Row Is Header

    If this option is selected the first row of your comma separated file is assumed to be the header. The names of the properties are generated using the field values in the first row. If the option is not selected the property names are generated automatically using a numeric pattern: column 1, column 2, column 3, etc. In the latter case the first row is interpreted as raw data.

    First Row is Header On

    [
      {
        "name": "Robin Hood",
        "department": "Sales",
        "salary": 200
      }
    ]

    First Row is Header Off

    [
      {
        "column 1": "Name",
        "column 2": "Department",
        "column 3": "Salary"
      },
      {
        "column 1": "Robin Hood",
        "column 2": "Sales",
        "column 3": 200
      }
    ]
  • 2. Delimiter

    The delimiter in the input CSV is specified here. In most cases the default setting Auto Detect works fine. But, in really small CSV data with delimiters also occurring as literals, the auto detection logic might not choose the correct delimiter. In such a scenario, the delimiter can be manually specified. Following are the choices for delimiters:-

    • Comma
    • Tab
    • Space
    • Pipe
    • Semi-Colon

  • 3. Indent

    This setting governs whether or not the output is indented. The indented output is easier for humans to comprehend. On the other hand, a non-indented output is compact & smaller in size (best for transmission). So, JSON is often minified which compacts & compresses the output by removing non-essential whitespace.

    Indentation On

    {
      "name": "John Doe",
      "age": 69
    }

    Indentation Off

    {"name":"John Doe","age":69}
  • 4. Header Transform Type

    This decides how the property names are transformed in the output JSON. The available strategies are:-

    • Camel Case
    • Lower Case
    • Upper Case
    • Snake Case
    • None

    Camel Case

    [
      {
        "name": "Robin Hood",
        "departmentName": "Sales",
        "salary": 200
      }
    ]

    Lower Case

    [
      {
        "name": "Robin Hood",
        "departmentname": "Sales",
        "salary": 200
      }
    ]

    Upper Case

    [
      {
        "NAME": "Robin Hood",
        "DEPARTMENTNAME": "Sales",
        "SALARY": 200
      }
    ]

    Snake Case

    [
      {
        "name": "Robin Hood",
        "department_name": "Sales",
        "salary": 200
      }
    ]

    None

    [
      {
        "Name": "Robin Hood",
        "DepartmentName": "Sales",
        "Salary": 200
      }
    ]
  • 5. Output Type

    This decides how the JSON output is transformed and supports the following modes:-

    The examples below assume the following input
    Name,Department,Manager,Salary
    Arsene Wenger,Bar,Friar Tuck,50
    Friar Tuck,Foo,Robin Hood,100
    Little John,Foo,Robin Hood,100
    Dimi Berbatov,Foo,Little John,50

    Properties

    This is the default output type. At the root of the output is a JSON array inside which there are multiple objects corresponding to a row in the input CSV.

    [
      {
        "Name": "Arsene Wenger",
        "Department": "Bar",
        "Manager": "Friar Tuck",
        "Salary": 50
      },
      {
        "Name": "Friar Tuck",
        "Department": "Foo",
        "Manager": "Robin Hood",
        "Salary": 100
      },
      {
        "Name": "Little John",
        "Department": "Foo",
        "Manager": "Robin Hood",
        "Salary": 100
      },
      {
        "Name": "Dimi Berbatov",
        "Department": "Foo",
        "Manager": "Little John",
        "Salary": 50
      }
    ]

    Column Arrays

    Here, the CSV data is transformed in a column oriented fashion. At the root of the output is a JSON object which has a property for each column in the input CSV. The value of each of these properties is a JSON array in which each item is taken from one of the data rows in the CSV.

    {
      "Name": [
        "Arsene Wenger",
        "Friar Tuck",
        "Little John",
        "Dimi Berbatov"
      ],
      "Department": [
        "Bar",
        "Foo",
        "Foo",
        "Foo"
      ],
      "Manager": [
        "Friar Tuck",
        "Robin Hood",
        "Robin Hood",
        "Little John"
      ],
      "Salary": [
        50,
        100,
        100,
        50
      ]
    }

    Row Arrays

    Here, the output is an Array of Array with no property names whatsoever. The structure is similar to the Properties output described above. But, there are no column names associated with the output. At the root of the output is a JSON array. Inside the array there are multiple arrays each of which correspond to a row in the input CSV. This inner array in turn is made of the values in each row. The order of the items is the same as in the input CSV.

    [
      [
        "Arsene Wenger",
        "Bar",
        "Friar Tuck",
        50
      ],
      [
        "Friar Tuck",
        "Foo",
        "Robin Hood",
        100
      ],
      [
        "Little John",
        "Foo",
        "Robin Hood",
        100
      ],
      [
        "Dimi Berbatov",
        "Foo",
        "Little John",
        50
      ]
    ]

    Dictionary Object

    Here, there are no arrays. The output at the root is a JSON object. Thereafter, the first column of each row becomes a property. The value of this property is another object with all the remaining columns in that row. You can think of the output as a Dictionary (in C#) or Map (in Java). The first column of each row must have unique value for this output type to give valid results.

    {
      "Arsene Wenger": {
        "Department": "Bar",
        "Manager": "Friar Tuck",
        "Salary": 50
      },
      "Friar Tuck": {
        "Department": "Foo",
        "Manager": "Robin Hood",
        "Salary": 100
      },
      "Little John": {
        "Department": "Foo",
        "Manager": "Robin Hood",
        "Salary": 100
      },
      "Dimi Berbatov": {
        "Department": "Foo",
        "Manager": "Little John",
        "Salary": 50
      }
    }

    Dictionary Array

    This is similar to Dictionary Object described above where the output at the root is a JSON object. Thereafter, the first column of each row becomes a property. The value of this property is an array as opposed to another object. The remaining values in each row become elements inside this array object.

    {
      "Arsene Wenger": [
        "Bar",
        "Friar Tuck",
        50
      ],
      "Friar Tuck": [
        "Foo",
        "Robin Hood",
        100
      ],
      "Little John": [
        "Foo",
        "Robin Hood",
        100
      ],
      "Dimi Berbatov": [
        "Foo",
        "Little John",
        50
      ]
    }
 

Comments 0


History

Sep 3, 2017
Major overhaul of settings
Aug 25, 2017
Tool Launched