A powerful Flask-based web application for converting, validating, and editing configuration files with an interactive tree visualization interface.
- Multi-Format Support: Convert between JSON, YAML, XML, TOML, and CSV
- Real-time Validation: Instant syntax checking and error detection
- Interactive Tree Editor: Visual hierarchy with drag-and-drop reorganization
- Batch Processing: Convert multiple files simultaneously
- Syntax Highlighting: Color-coded formatting for better readability
- File Upload/Download: Drag-and-drop or click to upload, one-click download
- Tree Manipulation:
- Drag nodes to reorder structure
- Edit keys and values inline
- Add/delete nodes
- Copy/paste functionality
- Keyboard shortcuts (Ctrl+C, Ctrl+V, Delete)
- Smart Conversion: Maintains data integrity during format changes
- Prettify/Minify: Format code for readability or compression
- Search: Find keys or values within the tree structure
- History: Undo/redo functionality (coming soon)
- Python 3.8 or higher
- pip (Python package manager)
- Clone the repository
git clone https://github.com/yourusername/format-converter-hub.git
cd format-converter-hub- Create a virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies
pip install -r requirements.txt- Create project structure
format-converter-hub/
β
βββ app.py # Main Flask application
βββ requirements.txt # Python dependencies
βββ templates/
β βββ index.html # HTML template (from artifact 1)
βββ static/
β βββ css/
β β βββ styles.css # Extract CSS from HTML
β βββ js/
β βββ tree-editor.js # Advanced tree editor module
βββ README.md # This file
- Run the application
python app.py- Open in browser
Navigate to
http://localhost:5000
- Paste or upload your configuration file in the input panel
- Select input format (auto-detected for uploaded files)
- Choose output format from the output panel
- View converted result instantly in the output editor
- Copy or download the converted file
- View hierarchy: See your configuration as an expandable tree
- Edit inline: Click on any key or value to edit directly
- Drag to reorder: Click and drag nodes to reorganize structure
- Add nodes: Click β button to add child nodes
- Delete nodes: Click ποΈ to remove nodes
- Copy/Paste: Use π and π₯ buttons or keyboard shortcuts
- Click "Batch Convert" button
- Select multiple files to upload
- Choose target format
- Download all converted files as a ZIP
POST /api/convert
Content-Type: application/json
{
"input_format": "json",
"output_format": "yaml",
"content": "{ \"key\": \"value\" }",
"prettify": true
}POST /api/validate
Content-Type: application/json
{
"format": "json",
"content": "{ \"key\": \"value\" }"
}POST /api/tree/update
Content-Type: application/json
{
"tree": [...],
"format": "json"
}POST /api/batch
Content-Type: multipart/form-data
files: [file1, file2, ...]
output_format: "json"| Format | Extensions | Features |
|---|---|---|
| JSON | .json | Full support, validation, prettify |
| YAML | .yaml, .yml | Full support, multi-document |
| XML | .xml | Full support, attributes, namespaces |
| TOML | .toml | Full support, sections, arrays |
| CSV | .csv | Basic support, flatten/unflatten |
- Maximum file size: 16MB
- Batch processing: Up to 50 files
- Tree visualization: Best for files under 1MB
Edit static/css/styles.css to customize colors:
:root {
--primary: #6366f1;
--secondary: #10b981;
--dark: #1f2937;
/* Add your colors */
}Configure in static/js/tree-editor.js:
const config = {
maxDepth: 10,
enableDragDrop: true,
enableInlineEdit: true,
enableKeyboardShortcuts: true
};app.py # Flask routes and converters
βββ FormatConverter # Conversion logic for all formats
βββ TreeGenerator # Tree structure generation
βββ Routes # API endpoints
static/
βββ css/ # Stylesheets
βββ js/ # JavaScript modules
βββ tree-editor.js # Tree manipulation logic
templates/
βββ index.html # Main UI template
- Add parser in
FormatConverterclass - Add converter method
- Update UI format buttons
- Add file extension to
ALLOWED_EXTENSIONS
# Run tests
python -m pytest tests/
# With coverage
python -m pytest --cov=app tests/FROM python:3.9-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["python", "app.py"]# Create Procfile
echo "web: gunicorn app:app" > Procfile
# Deploy
heroku create your-app-name
git push heroku mainexport FLASK_ENV=production
export SECRET_KEY=your-secret-key
export MAX_CONTENT_LENGTH=16777216- Import Error for yaml/toml
pip install PyYAML toml- CORS Issues
# In app.py
from flask_cors import CORS
CORS(app, origins="*")- Large File Handling
app.config['MAX_CONTENT_LENGTH'] = 32 * 1024 * 1024 # 32MB- Fork the repository
- Create feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Flask framework
- PyYAML for YAML processing
- TOML library for TOML support
- Tree visualization inspired by VS Code's file explorer
For issues, questions, or suggestions:
- Open an issue on GitHub
- Email: support@formatconverter.com
- Documentation: https://docs.formatconverter.com
Made with β€οΈ by [Your Name]# Configuration_File_Visualizer