This Python script converts JSON data into an Excel file format (.xlsx). It works on macOS, Linux, and Windows, offering both interactive and command-line options for a smooth and flexible experience.
- ✅ Cross-Platform Support: Works seamlessly on macOS, Linux, and Windows.
- 🧰 Optional Command-Line Arguments: Supports
--inputand--outputflags to skip interactive prompts. - 🍎 macOS Integration: Uses native AppleScript dialogs for selecting files and folders.
- 📦 Automatic Dependency Installation: Installs required Python packages (
pandas,openpyxl) if not already installed. - 📁 Smart Defaults: If no output is specified, saves the Excel file in the same location as the JSON file.
- 📂 Auto Open Output Folder: Opens the output folder automatically after conversion on all platforms.
- Python 3.x
pandas: For working with tabular data.openpyxl: For Excel file creation and editing.
✨ No need to manually install dependencies — the script will offer to install them for you.
-
Clone or download this repository:
git clone https://github.com/your-repo/json-to-excel.git cd json-to-excel -
(Optional) Manually install requirements:
python3 -m pip install pandas openpyxl
Run the script and follow the prompts:
python3 json_to_excel.py- macOS: Native dialogs appear for file and folder selection.
- Other Platforms: Prompts will appear in the terminal.
python3 json_to_excel.py --input /path/to/input.json --output /path/to/output.xlsxThis bypasses prompts and runs headlessly.
python3 json_to_excel.py --input ./data/myfile.jsonOutput will be saved as ./data/myfile.xlsx.
- Checks Dependencies: Installs
pandasandopenpyxlif needed. - Handles Input: Reads from command-line or prompts user.
- Converts JSON: Uses
pandasto turn JSON into an Excel spreadsheet. - Saves Output: Exports
.xlsxfile and opens output folder.
- Missing Dependencies: The script will install them if you approve.
- Invalid Paths: Ensure the input file exists and is valid JSON.
- macOS-only Dialogs: File/folder dialogs are only available on macOS. Other platforms fall back to terminal prompts.