不同语言: 中文文档
A powerful offline formatting desktop application built with Python + PyQt5, supporting both JSON and XML formats. Provides Postman Beautify-like functionality with additional features including sorting, compression, validation, tree view, and advanced search & replace capabilities.
- 🚀 Completely Offline: No internet connection required, protecting your data privacy
- 🎨 Modern Interface: Beautiful GUI design with embedded search and replace functionality
- ⚡ High Performance: Built on PyQt5 for fast and responsive user experience
- 🔧 Multiple Formatting Options: Beautify, sort, minify, and validate JSON & XML with ease
- 📄 Dual Format Support: Seamlessly switch between JSON and XML processing modes
- 📋 Convenient Operations: One-click copy, clear, with keyboard shortcuts support
- 🎯 Precise Search: Case-sensitive and whole-word matching search & replace
- 🌈 Smart Highlighting: Modern blue background with white text and bold formatting for search results
- 🌳 Tree View: Expandable/collapsible JSON & XML structure tree for intuitive hierarchy visualization
- 🔄 Dual View Mode: Text view and tree view with real-time synchronization
Main Interface
- Top: Format selector (JSON/XML) with seamless switching
- Left panel: Input area (editable) - supports both JSON and XML
- Right panel: Output area (read-only) with dual view mode (Text/Tree)
- Bottom: Function buttons and embedded search/replace tools
- Download the latest
JSON格式化工具.exefrom the Releases page - Double-click to run - no Python installation required!
# Clone the repository
git clone https://github.com/your-username/offline-json-formatter.git
cd offline-json-formatter
# Install dependencies
pip install -r requirements.txt
# Run the application
python main.py- Beautify: Format JSON/XML with proper indentation (4 spaces)
- Sort: Sort JSON keys or XML elements alphabetically and beautify
- Minify: Compress JSON/XML to single line
- Validate: Check JSON/XML syntax validity
- Copy: Copy formatted result to clipboard
- Expand All: Expand all nodes in tree view
- Collapse All: Collapse all nodes in tree view
- Clear: Clear both input and output areas
- Seamless Toggle: Switch between JSON and XML modes instantly
- Auto UI Update: Interface adapts automatically to selected format
- Independent Processing: Each format maintains its own processing logic
- Text View: Traditional text format display with search and replace support
- Tree View: Interactive JSON/XML structure tree with expandable/collapsible nodes
- Tab Switching: Seamlessly switch between views with real-time data synchronization
- Format-Aware Trees: Dedicated tree widgets for JSON and XML with format-specific rendering
- Embedded Search Box: Integrated search interface in text areas
- Advanced Options: Case-sensitive and whole-word matching
- Modern Highlighting: Blue background with white text and bold formatting
- Navigation: Previous/Next buttons for easy navigation
- Replace Functions: Replace current match or replace all occurrences
- Font Size Control: Adjustable font sizes for better readability
- Keyboard Shortcuts: Ctrl+F for search, Ctrl+H for replace
- Error Handling: Detailed error messages for invalid JSON
- Status Bar: Real-time feedback on operations
- Operating System: Windows 7/10/11/Windows Server
- Python Version: 3.8+ (if running from source)
- Memory: 2GB RAM recommended
- Disk Space: 50MB for executable, 100MB for source installation
pip install pyinstaller
pyinstaller --onefile --windowed --name="JSON格式化工具" main.py# Use the optimization script
build_optimized.bat# Use spec configuration file
build_small.bat-
Install UPX compression tool
- Download: https://github.com/upx/upx/releases
- Extract to system PATH or project directory
-
Manual compression
upx --ultra-brute "dist\JSON格式化工具.exe"
Input:
{"name":"John Doe","age":30,"city":"New York","skills":["Python","JavaScript"]}After Beautify:
{
"name": "John Doe",
"age": 30,
"city": "New York",
"skills": [
"Python",
"JavaScript"
]
}After Sort:
{
"age": 30,
"city": "New York",
"name": "John Doe",
"skills": [
"Python",
"JavaScript"
]
}Input:
<person><name>John Doe</name><age>30</age><city>New York</city><skills><skill>Python</skill><skill>JavaScript</skill></skills></person>After Beautify:
<person>
<name>John Doe</name>
<age>30</age>
<city>New York</city>
<skills>
<skill>Python</skill>
<skill>JavaScript</skill>
</skills>
</person>After Sort:
<person>
<age>30</age>
<city>New York</city>
<name>John Doe</name>
<skills>
<skill>JavaScript</skill>
<skill>Python</skill>
</skills>
</person>- Open Search: Press
Ctrl+For click the search button - Enter Search Term: Type the text you want to find
- Navigate Results: Use ↑/↓ buttons to navigate matches
- Replace Text: Use
Ctrl+Hfor replace functionality - Advanced Options: Toggle case sensitivity and whole-word matching
- Language: Python 3.8+
- GUI Framework: PyQt5 5.15+
- JSON Processing: Python standard library
json - XML Processing: Python standard library
xml.etree.ElementTree - Packaging: PyInstaller 6.3.0
offline-json-formatter/
├── main.py # Main application file
├── requirements.txt # Python dependencies
├── README.md # Chinese documentation
├── README_EN.md # English documentation
├── LICENSE # MIT license file
├── build_optimized.bat # Optimized build script
├── build_small.bat # Ultra-compact build script
├── main_optimized.spec # PyInstaller spec file
└── dist/ # Build output directory
└── JSON格式化工具.exe # Executable file
- JSONFormatterApp: Main window class inheriting from QMainWindow
- EmbeddedSearchWidget: Embedded search functionality
- EmbeddedReplaceWidget: Embedded search & replace functionality
Q: Application won't start
A: Ensure PyQt5 is installed: pip install PyQt5
Q: JSON formatting fails A: Verify input is valid JSON format. The application will show specific error messages.
Q: Executable file is too large A: This is normal as it includes Python runtime and PyQt5 libraries. Use optimized build scripts for smaller size.
Q: Error on Windows 7 A: Ensure Visual C++ Redistributable is installed on the system.
Q: Search highlighting not working A: The new blue highlighting system requires proper QTextCharFormat support. Restart the application if issues persist.
- 🌳 New JSON Tree View: Implemented expandable/collapsible JSON structure tree display
- 🔄 Dual View Mode: Added text view and tree view tabs with real-time switching
- 📂 Tree Operations: New "Expand All" and "Collapse All" buttons for quick tree manipulation
- 🎨 Visual Enhancements: Tree view supports alternating row colors and modern styling
- ⚡ Performance Optimization: Improved tree display performance for large JSON data
- 🔍 New Search & Replace: Added embedded search box with modern blue highlighting
- 🎨 UI Improvements: Enhanced search match highlighting with blue background + white text + bold formatting
- 🐛 Bug Fixes: Resolved QTextDocument.find parameter type errors
- ⚙️ Feature Enhancements: Added circular search, case sensitivity, and whole-word matching options
- 🔧 Feature Extensions: Added font size adjustment functionality
- 📱 Interface Improvements: Optimized layout and user experience
- 🎯 Error Handling: Enhanced JSON validation and error messaging
- ✅ Implemented basic JSON formatting functionality
- ✅ Added JSON sorting feature
- ✅ Implemented clipboard copy functionality
- ✅ Added clear function and error handling
- ✅ Extended features: Minify and Validate
- ✅ Beautiful GUI interface design
- ✅ Complete packaging and distribution solution
We welcome Issues and Pull Requests to help improve this project!
git clone https://github.com/your-username/offline-json-formatter.git
cd offline-json-formatter
pip install -r requirements.txt
python main.py- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Author: wangjunqi
- Current Version: 0.1
- Development Period: 2025.09
If this project helps you, please give it a ⭐ Star!
- 中文文档 - Chinese Documentation
- English Documentation - This file
🎉 Thank you for using Offline JSON Formatter! For questions or suggestions, feel free to open an issue.