JSON to CSV Converter
Convert JSON data to CSV format for Excel viewing and analysis
Overview
JSON is a common format for data exchange between programs, but it's not easy for humans to read. Claude can help you convert JSON data to CSV spreadsheet format, which can be opened with Excel, Numbers, and other tools for easy viewing, analysis, and editing.
Use Cases
- Export API-returned JSON data as spreadsheets
- Convert log files to CSV for easier analysis
- Process database exports in JSON format
- Merge multiple JSON files into one CSV
Steps
Step 1: Analyze JSON Structure
First, let Claude understand the JSON data structure.
Please analyze the ~/data/users.json file:
- Data structure (is it an object or array? What fields are there?)
- Nesting levels
- Total record count
- Suggestions for converting to CSV format
Step 2: Simple Conversion
Convert a simple JSON array to CSV.
Please convert ~/data/users.json to CSV:
- Output file: ~/data/users.csv
- Include header row
- Use comma as delimiter
- Date format: YYYY-MM-DD
- Handle commas and line breaks in fields (wrap with quotes)
Step 3: Handle Nested Data
For JSON containing nested objects or arrays.
users.json has nested address objects and tags arrays for each user, please:
- Flatten address.city and address.country into separate columns
- Convert tags array to semicolon-separated string
- Generate flattened CSV file
Step 4: Batch Conversion
Convert multiple JSON files.
Please convert all .json files in ~/data/logs folder to CSV:
- Generate corresponding CSV file for each JSON
- If JSON structures are the same, can merge into one CSV
- Save to ~/data/csv_output folder
- Generate conversion report
Step 5: Custom Field Selection
Convert only the fields you need.
From users.json, extract only these fields to CSV:
- id
- name
- email
- created_at
Ignore other fields, sort by id for output
Note: CSV format doesn't support complex nested structures. If JSON data has deep nesting, you need to decide how to flatten the data, which may lose some structural information.
Tip: For data containing Chinese characters, make sure the CSV file uses UTF-8 with BOM encoding so Excel can display Chinese characters correctly.
FAQ
Q: Chinese characters appear garbled when opening CSV in Excel? A: Ask Claude to export using UTF-8 with BOM encoding, or import in Excel via "Data > From Text" and select UTF-8 encoding.
Q: Commas in fields cause column misalignment? A: Standard CSV format wraps fields containing commas with double quotes. Ensure escape characters are properly handled during conversion.
Q: Can very large JSON files be converted? A: Yes, but for very large files (hundreds of MB or more), batch processing is recommended to avoid memory overflow. Claude can write scripts for streaming large files.