JSON Cleaner
FV-40Paste messy JSON and get valid, tidy JSON back. It fixes syntax slips such as comments, single quotes and trailing commas, and can drop null values, empty strings and empty objects or arrays.
Runs in your browser. Nothing is uploaded.
JSON (comments, single quotes and trailing commas are accepted)
Clean JSON
How to use it
- Paste your JSON. Comments, single-quoted strings and trailing commas are accepted.
- Tick what to remove: null values, empty strings, empty objects and arrays. Tick Trim spaces around string values or Sort keys A to Z if you want them.
- Choose an indent, or Minified, and press Clean JSON. Press Clean and minify for one line.
- Press What changed to see which syntax fixes were made and how many values were removed.
Two stages: repair, then clean
First the text is repaired with the same engine as the JSON Fixer tool: comments are removed, single quotes become double quotes, trailing commas are dropped and similar slips are fixed. It never makes up a value, so a missing value or an unterminated string stops with an error. Then the clean-up options run on the valid data. Numbers are kept exactly as you wrote them, so a 20-digit ID is not rounded the way it would be by JSON.parse.
What removal does to your data
Removing a null value or an empty string deletes the key from an object. In an array it deletes the item, so the later items move up and change position. An object that becomes empty after its keys are removed is removed too when the empty-object option is on, all the way up, but the top-level value is always kept. Trimming changes the text inside strings, and the result can still be correct JSON that means something different to your application, so check it before you use it.
Sort keys and layout
Sort keys A to Z orders object keys at every level and leaves arrays in their original order. The indent menu sets 2 or 4 spaces, a tab, or a minified single line. String contents keep their meaning, but a string that you trim is written back with standard JSON escapes, so a character that was written as a code in the input can appear as the character itself.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
Paste the JSON to clean. | The input box is empty or holds only whitespace. | Paste the JSON you want to clean. |
Questions people ask
How do I clean messy JSON?
Paste it and press Clean JSON. Comments, single quotes and trailing commas are fixed, then the options you ticked remove null values, empty strings and empty objects, and the result is indented. Press What changed for a list of fixes.
How do I remove null values from JSON?
Keep Remove null values ticked and press Clean JSON. Keys whose value is null are deleted from objects, and null items are deleted from arrays, which moves the later array items up by one.
Does it round large numbers?
No. Numbers are copied exactly as written, so an integer such as 12345678901234567890 comes out unchanged. Tools built on JSON.parse would turn it into 12345678901234567000.
Can it fix JSON with comments?
Yes. Comments that start with two slashes or are wrapped in slash-star pairs are removed. Standard JSON does not allow comments, so the output is plain valid JSON without them.
Does cleaning change my data?
Syntax fixes do not. The removal and trim options do, by design: they delete values and change string contents. Untick them to only repair and reformat. Use What changed to see the counts.
What is the difference between a JSON cleaner and a JSON formatter?
A formatter only changes layout and needs valid JSON. A cleaner also repairs invalid syntax and can remove values. Use the JSON formatter if your data is already valid and you only want indentation.
About this tool
The JSON is first repaired with the same engine as the JSON Fixer tool: comments are dropped, single quotes become double quotes, trailing commas are removed and similar syntax slips are fixed. It never invents a value, so a missing value or an unterminated string stops with an error. Then the optional clean-up runs. Removing a value from an array moves the later items up, which changes their positions, and removing the last key of an object can leave it empty, which the empty-object option then removes in turn. Trimming changes the data inside strings. Numbers are kept exactly as written, so large integers are not rounded. The top-level value is never removed. Everything runs in your browser and nothing is uploaded.