json-cleanfix
v1.0.0
Published
A soft JSON parser that cleans invalid JSON by removing comments, fixing quotes, and trailing commas.
Maintainers
Readme
🧹 json-cleanfix
A soft JSON parser that cleans and fixes dirty JSON strings.
Removes comments, trailing commas, improper quotes, unquoted keys, and replaces invalid values like NaN and undefined.
✅ Why use this?
Real-world JSON often comes from messy sources — config files, user input, or logs. This utility:
- Removes single-line (
//) and block (/* ... */) comments - Replaces single quotes (
') with double quotes (") - Removes trailing commas
- Adds quotes to unquoted keys
- Converts
NaNandundefinedtonull - Strips invalid escape characters
Perfect for preprocessing before safely calling
JSON.parse().
📦 Installation
npm install json-cleanfix