A powerful tool that converts JSON files into interactive HTML explorers with a Windows Explorer-like interface. Navigate through complex JSON structures with ease using an intuitive tree view and content viewer.
- Interactive Tree View: Navigate JSON structure with expandable/collapsible nodes
- Content Viewer: View detailed JSON content with syntax highlighting
- Windows Explorer-like Interface: Familiar two-pane layout
- File Validation: Comprehensive JSON validation with detailed error messages
- Error Handling: Robust error handling with actionable guidance
- Responsive Design: Clean, modern interface that works on different screen sizes
- Batch Processing: Process multiple JSON files with timestamped outputs
- Python 3.7+
- loguru (for logging)
- Clone the repository:
git clone https://github.com/rubenxyz/json->html_tool.git
cd json->html_tool
- Create a virtual environment:
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
Convert a JSON file to HTML:
python json_to_html.py input/sample.json
Specify custom output path:
python json_to_html.py input/sample.json output/custom_name.html
The tool follows a simple workflow:
- Input: JSON files placed in the
input/
directory - Output: HTML files generated in timestamped folders under
output/
Example output structure:
output/
βββ 2025-07-21_07-31-40/
β βββ sample.html
β βββ conversion_log.json
β βββ conversion_summary.md
βββ 2025-07-21_08-15-22/
βββ another_file.html
βββ conversion_log.json
βββ conversion_summary.md
- π Objects: Expandable folders for JSON objects
- π Arrays: Expandable lists for JSON arrays
- π Primitives: Individual values (strings, numbers, booleans, null)
- Count Indicators: Shows number of items in objects/arrays
- Auto-expansion: First two levels automatically expanded
- Syntax Highlighting: Color-coded JSON values by type
- Path Display: Shows current node path
- File Information: Displays file name, size, and type
- Formatted Display: Clean, readable JSON presentation
- Click to Select: Click any node to view its content
- Expand/Collapse: Click arrow icons to expand/collapse nodes
- Visual Feedback: Selected nodes are highlighted
The tool supports various configuration options:
config = {
'title': 'JSON Explorer', # HTML page title
'theme': 'light', # Theme (light/dark)
'auto_expand_levels': 2, # Auto-expand first N levels
'show_line_numbers': True, # Show line numbers in content
'enable_syntax_highlighting': True # Enable syntax highlighting
}
The tool provides comprehensive error handling for various scenarios:
- File Not Found: Clear path guidance
- Permission Denied: Permission troubleshooting
- Empty Files: Validation for empty JSON files
- File Too Large: Size limit enforcement (100MB max)
- Invalid Extension: Only .json files supported
- Syntax Errors: Line-specific error reporting
- Encoding Issues: UTF-8 encoding validation
- Structure Problems: Deep nesting and size validation
- Invalid Types: Unsupported data type detection
Each error includes:
- Clear error description
- Error code for programmatic handling
- Actionable guidance for resolution
- Line numbers for syntax errors
json->html_tool/
βββ json_to_html.py # Main entry point
βββ input_detector.py # JSON file validation
βββ json_parser.py # JSON parsing and analysis
βββ html_generator.py # HTML generation
βββ requirements.txt # Python dependencies
βββ input/ # Input JSON files
β βββ sample.json
β βββ invalid.json
βββ output/ # Generated HTML files
βββ .taskmaster/ # Project management
βββ docs/
β βββ prd.txt # Product requirements
βββ tasks/
βββ tasks.json # Development tasks
- Valid JSON:
input/sample.json
- Comprehensive test data - Invalid JSON:
input/invalid.json
- Error handling tests
Test with valid JSON:
python json_to_html.py input/sample.json
Test error handling:
python json_to_html.py input/invalid.json
python json_to_html.py input/nonexistent.json
python json_to_html.py input_detector.py
"ModuleNotFoundError: No module named 'loguru'"
source venv/bin/activate
pip install -r requirements.txt
"Input file must have .json extension"
- Ensure your file has a
.json
extension - Only JSON files are supported
"Invalid JSON format"
- Check the JSON syntax using a JSON validator
- Look for missing quotes, commas, or brackets
- Ensure proper UTF-8 encoding
"File is too large"
- Split large JSON files into smaller chunks
- Maximum file size is 100MB
- Check the conversion logs in the output directory
- Review the error messages for specific guidance
- Ensure your JSON file is valid using online validators
- Check file permissions and encoding
The tool follows a modular architecture:
- Input Detection (
input_detector.py
): Validates and analyzes JSON files - JSON Parsing (
json_parser.py
): Parses JSON and prepares tree structure - HTML Generation (
html_generator.py
): Creates interactive HTML interface - Main Orchestration (
json_to_html.py
): Coordinates the entire process
To extend the tool:
- New Validation Rules: Add to
validate_json_structure()
ininput_detector.py
- UI Enhancements: Modify CSS and JavaScript in
html_generator.py
- New Output Formats: Extend
html_generator.py
with new generators - Configuration Options: Add to the config dictionary in
json_to_html.py
This project is open source and available under the MIT License.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
For issues, questions, or contributions:
- Open an issue on GitHub
- Check the troubleshooting section
- Review the error logs in the output directory
Happy JSON Exploring! π