FormatterHQ

JSON Cleaner

Strip null values, empty strings, empty arrays and empty objects from JSON at every depth, optionally trim whitespace in strings, and see how many values were removed.

Input JSON
Output JSON
Ready.

How to use the JSON Cleaner

  1. Paste or upload the JSON you want to clean, or click Sample.
  2. Tick the kinds of values to remove: Remove null, Remove empty strings, Remove empty arrays, Remove empty objects. Add Trim whitespace in strings if needed.
  3. Pick an Indent and click Clean JSON.
  4. Check the "Removed N empty values" message, then copy or download the cleaned JSON.

What the JSON cleaner removes

API responses, form submissions and exported records are often padded with fields that carry no data: null placeholders, empty strings, empty lists and empty objects. This JSON cleaner walks the whole document and drops those values at every level of nesting, so what remains is the data that actually says something.

Example

{
  "id": 42,
  "title": "  Q3 report ",
  "note": "   ",
  "author": null,
  "tags": [],
  "stats": {"shares": null, "comments": []},
  "items": [null, "", 0, false]
}

With the default options the result is below, and the status bar reads "Removed 8 empty values":

{
  "id": 42,
  "title": "  Q3 report ",
  "items": [
    0,
    false
  ]
}

How cleaning works, level by level

The cleaner works from the inside out. Children are cleaned first, and only then is the parent checked. In the example, stats loses shares and comments, is left as {}, and is then removed as an empty object too. That is why eight values were counted: seven empty fields plus the stats object that became empty.

The same cascade applies to arrays. Empty entries are removed from lists, so [null, "", 0, false] shrinks to [0, false]. The top-level value itself is never removed; a document that is entirely empty comes back as {} or [].

Options

  • Remove null – drops keys and array entries whose value is null.
  • Remove empty strings – drops "" and also strings that contain only spaces, tabs or line breaks, like " " above.
  • Remove empty arrays – drops [], including arrays that become empty after cleaning.
  • Remove empty objects – drops {}, including objects emptied by cleaning. Turn it off to keep the structure, for example {"a":{"b":{"c":null}}} then becomes {"a":{"b":{}}}.
  • Trim whitespace in strings – off by default; removes leading and trailing whitespace from the strings that remain, so " Q3 report " becomes "Q3 report". Spaces inside a value are kept.
  • Indent – 2, 3 or 4 spaces or a tab for the output.

The first four options are on by default. Values such as 0, false and "0" are real data and are never removed.

Typical uses

  • Shrinking a stored document or a fixture before committing it, when empty fields add noise but no meaning.
  • Reading a verbose API response, where dozens of null fields hide the handful that are set.
  • Preparing records for a JSON to CSV export, so that empty nested objects do not turn into empty columns.

When not to clean

An empty value is not always meaningless. In a JSON Merge Patch request (the PATCH format of RFC 7396), "field": null means "delete this field", so removing it silently changes the request. Some APIs also distinguish between a missing key and an empty list, for example "no tags" versus "tags not loaded". Clean data you are going to read, archive or compare; think twice before cleaning data you are about to send back to the same API.

Related tools

Cleaning pairs well with a JSON diff when two payloads differ only in empty fields, and with the JSON minifier when the goal is a smaller payload. If the input does not parse, run it through the JSON fixer first.

All cleaning happens in your browser; the JSON is not uploaded unless you use Load URL or Save & Share.

Frequently asked questions

How do I remove null values from JSON?
Paste the JSON, leave Remove null ticked and untick the other removal options if you want to keep empty strings, arrays and objects. Click Clean JSON and every null in objects and arrays is dropped.
Does the cleaner remove 0 and false?
No. Zero, false and the string "0" are real values, so they are always kept. Only null, empty or whitespace-only strings, empty arrays and empty objects can be removed.
Why was a whole object removed when I only had null fields in it?
After its null fields were removed the object was empty, and Remove empty objects is on by default. Untick that option to keep empty parent objects.
Are whitespace-only strings treated as empty?
Yes. With Remove empty strings on, a value like " " is removed even when Trim whitespace in strings is off.
Does cleaning change the order of keys?
No. The remaining keys stay in their original order and array elements keep their relative positions.

Last updated September 26, 2026

Related tools

JSON Decode Online Decode JSON strings online. Convert escaped or encoded JSON text into readable, formatted JSON, similar to json_decode. JSON Deserialize Online Deserialize an escaped JSON payload into formatted JSON, then map it to typed objects in JavaScript, Python, Java or C# safely. JSON Editor Edit JSON online with a live tree preview, instant validation and one-click formatting, repair and minification. JSON Encode Online JSON encode text or a document into an escaped string, with each escaping rule explained and the json_encode flags that give identical output. JSON Fixer & Repair Fix broken JSON automatically: add missing quotes, commas and brackets, remove comments and trailing commas, and convert Python literals. JSON Flatten Flatten nested JSON into single-level key paths like user.address.city, with dot, custom or bracket notation for arrays. JSON Formatter Format, beautify and validate JSON online. Pretty print minified JSON with 2, 3, 4 space or tab indentation and pinpoint syntax errors. JSON Merge Patch (RFC 7396) Apply an RFC 7396 JSON Merge Patch to a document, or create the merge patch that turns one JSON document into another. JSON Minify Minify JSON by removing whitespace and line breaks. Shrink payloads for APIs, storage and embedding, and see the bytes saved. JSON Multiline String Converter Convert multi-line text into a valid JSON string with \n escapes, a JSON array of lines, or concatenated string literals. JSON Navigator Navigate JSON by path. Browse or filter the tree and click any key to see and copy the full path to that value. JSON Parser Parse JSON online: errors with line and column, the parsed values with their types, and the pitfalls of big integers and duplicate keys.