✨ Transform messy JSON into clean, structured beauty! This lightweight tool tackles malformed, double-encoded, or deeply nested JSON with ease, whether you're wrangling legacy API data or prepping for database imports. Available as a Node.js CLI for batch processing and a web app for interactive cleaning.
🌐 Try it live: ttech-json-formatter.netlify.app
JSON Cleaner & Formatter is your go-to solution for taming chaotic JSON. It handles:
- Double-encoded strings (
"{\"key\": \"value\"}") - Stray slashes (
\/), trailing commas, and unquoted keys - Nested stringified JSON (e.g.,
data.updated.updatedorinvoice.attachment) - Broken or inconsistent formatting
Whether you're a developer, data engineer, or QA analyst, this tool saves time and headaches with fault-tolerant parsing and pretty-printed output.
json-cleaner/
├── rawdata.txt # 🔍 Input file for messy JSON (Node.js CLI)
├── cleanJson.json # ✅ Cleaned and formatted JSON output
├── index.html # 🌐 Web interface for interactive cleaning
├── style.css # 🎨 Styles for the web app
├── script.js # 🧠 JavaScript logic for the web app
├── main.js # 🚀 Node.js script for CLI cleaning
└── README.md # 📖 You're here!
- Reads: Loads raw JSON from
rawdata.txt. - Cleans:
- Parses stringified fields like
data.updated.updated(arrays) andinvoice.attachment(objects). - Fixes common issues: trailing commas, single quotes, control characters, and more.
- Parses stringified fields like
- Outputs: Writes pretty-printed JSON to
cleanJson.json.
- Input: Paste messy JSON into the browser interface.
- Process: Cleans and formats with real-time diagnostics.
- Output: Displays readable JSON with options to copy or download.
- Skips unparseable fields with warnings (e.g.,
⚠️ Could not parse attachment for invoice: INV-12345). - Logs detailed diagnostics to console and web UI.
- Handles up to 5MB of input with robust error recovery.
- Visit ttech-json-formatter.netlify.app.
- Paste your messy JSON in the input textarea.
- Click Clean & Format, Beautify, or Minify.
- Copy or download the cleaned JSON. 🎉
- Clone the repo:
git clone https://github.com/yourusername/json-cleaner.git cd json-cleaner - Add your JSON: Place raw JSON in
rawdata.txt. - Run the script (requires Node.js v12+):
node main.js
- Check output:
✅ Clean JSON written to cleanJson.json
- Dual Modes: Interactive web app and lightweight CLI.
- Robust Parsing:
- Attempts raw
JSON.parsefirst. - Removes control characters and stray bytes.
- Fixes trailing commas, collapses backslashes, and converts single quotes to double.
- Quotes unquoted keys conservatively.
- Extracts JSON-like substrings from noisy input.
- Recursively parses nested stringified JSON.
- Attempts raw
- User-Friendly Web UI:
- Real-time loader and diagnostics.
- Interactive buttons with hover effects and toast notifications.
- Copy/download cleaned JSON with one click.
- Lightweight: CLI uses only native Node.js
fsandpath. Web app uses minimal dependencies (jQuery, Toastr, Tailwind CSS). - Pretty Output: Consistent indentation for readability.
- API Cleanup: Normalize double-encoded JSON from legacy systems.
- Database Prep: Standardize data for smooth imports.
- Debugging: Validate and format JSON for automation or manual QA.
- Prototyping: Quickly test and clean JSON during development.
- Node.js CLI: Node.js v12+ (no external libraries).
- Web App:
- Modern browser (Chrome, Firefox, Safari, etc.).
- CDN dependencies: jQuery, Toastr, Tailwind CSS.
| Web App Interface | CLI Output |
|---|---|
Note: Replace placeholder images with actual screenshots for a polished look!
MIT License — Free to use, modify, and share.
We 💖 contributions! To get started:
- Fork the repo.
- Create a branch (
git checkout -b feature/cool-idea). - Commit your changes (
git commit -m "Add cool feature"). - Push to the branch (
git push origin feature/cool-idea). - Open a pull request!
Found a bug? Have a feature idea? Open an issue!
- ⭐ Star the repo to show your support!
- Try the live demo and share feedback.
- Join the open-source community by contributing code, docs, or ideas.
- Modernized: Added a cool, developer-friendly tone with emojis for emphasis without clutter.
- Web + CLI: Clearly documents both the web app and Node.js CLI, integrating the
<DOCUMENT>details (e.g., repair steps, 5MB limit, example JSON). - Deployed Link: Prominently features the Netlify link for instant access.
- Visual Appeal: Includes a screenshot section (with placeholders—replace with real images for max impact).
- Call to Action: Encourages starring the repo and contributing to build community engagement.
- Placeholders: Replace
Your Name, GitHub/LinkedIn links, and screenshot URLs with your details.
Let me know if you want to add specific examples, a FAQ, or further tweaks to make it even cooler! 😎