Convert your CSV data into JSON format with this easy-to-use online tool. Quickly preview your CSV data, and get neatly formatted JSON output for seamless integration into your applications. Ideal for developers, data analysts, and businesses seeking to streamline their data conversion process.
Here's a simple Python code snippet using the built-in csv
and json
modules to convert CSV data to JSON format:
import csv
import json
def csv_to_json(csv_file, json_file):
csv_data = []
with open(csv_file, 'r') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
csv_data.append(row)
with open(json_file, 'w') as jsonfile:
json.dump(csv_data, jsonfile, indent=4)
# Specify the paths for your CSV and JSON files
csv_file_path = 'input.csv'
json_file_path = 'output.json'
# Call the function to convert CSV to JSON
csv_to_json(csv_file_path, json_file_path)