Skip to content
LocalOnly

Remove Nulls from JSON

Stable

Recursively strip every null value from a JSON document.

Everything is processed locally in your browser

About Remove Nulls from JSON

The Remove Nulls tool walks your entire JSON document and deletes every property whose value is null, at any depth. This produces leaner payloads and cleaner configs where absent data is simply omitted rather than explicitly set to null. You control whether nulls inside arrays are dropped or preserved to keep positions intact.

Features

  • Recursively removes null-valued properties from every nested object
  • Optionally drops null elements inside arrays or keeps them to preserve indices
  • Leaves all non-null values, including false, 0, and empty strings, untouched
  • Optionally prunes objects that become empty after nulls are removed
  • Reports how many null values were removed
  • Copy the cleaned document in one click

How to use Remove Nulls from JSON

  1. 1

    Paste your JSON

    Add the document that contains null values you want to clean up.

  2. 2

    Configure array handling

    Choose whether null elements inside arrays are removed or kept in place.

  3. 3

    Remove nulls

    The tool deletes every null property throughout the structure.

  4. 4

    Copy the result

    Use the leaner JSON in your API request, config, or storage.

Examples

Stripping null properties

Input

{
  "id": 5,
  "nickname": null,
  "profile": {
    "bio": null,
    "avatar": "a.png"
  }
}

Output

{
  "id": 5,
  "profile": {
    "avatar": "a.png"
  }
}

How removing nulls from JSON works

Stripping nulls is a change of meaning, not a cleanup

This is the one thing to understand before using this tool. In JSON, an explicit `null` and an absent key are different states, and well-designed APIs rely on the difference. `{"nickname": null}` says the nickname is known to be empty. `{}` says nothing about the nickname at all. Removing the null converts the first statement into the second, which is a semantic edit rather than a formatting tidy-up.

The clearest place this bites is a PATCH request. In JSON Merge Patch (RFC 7396), `null` is the instruction to delete a field, and omitting a field means leave it alone. Strip the nulls from a merge patch and every deletion silently becomes a no-op. The request still succeeds, and the fields you meant to clear stay exactly as they were.

So the question to ask is not whether nulls look untidy, but whether the consumer distinguishes null from absent. If it does, do not strip them. If it does not, stripping is safe and often useful.

When removing nulls is the right call

Reading is the best reason. An API response that returns every field of a wide record produces documents where most values are null, and the handful of populated fields are buried. Stripping the nulls for a debugging session makes the actual data visible - and because you are only reading, changing the meaning costs nothing.

Payload size is the second. A response with hundreds of optional fields can be dominated by nulls, and removing them can cut it substantially. This is a legitimate optimisation when the client treats missing and null identically, which is the common case for read-only display code.

Storage is the third. Document databases charge for what you store, and a null field occupies a key and a value in every record. If your schema treats absence as null anyway, not writing the key is free savings.

Why arrays are handled differently

Removing a null from an object drops a key. Removing a null from an array shifts every element after it down one index, which changes the meaning of every subsequent position. If anything references `items[3]`, or if a parallel array lines up positionally with this one, that reference is now wrong.

Because of that asymmetry, null removal inside arrays deserves separate thought from null removal inside objects. Where array positions are meaningful - time series with gaps, fixed-length records, parallel arrays - nulls are load-bearing and must stay. Where the array is just a bag of values, compacting it is harmless.

Which tool should you use?

These tasks overlap. Here is how to pick the right one for what you are actually doing.

You are reading a wide API response and the real data is buried
Strip the nulls. You are only looking, so the change in meaning has no consequences.
You also want empty strings, objects and arrays gone
The JSON Remove Empty Values tool casts a wider net. This tool touches `null` and nothing else.
You are building a PATCH request
Do not strip nulls. In JSON Merge Patch, `null` is the delete instruction, and removing it turns a deletion into a no-op.
You need the document smaller for transport
Try the JSON Minifier first - it reduces size without touching meaning at all.

Use cases

  • Trimming null fields from an API payload before sending it
  • Cleaning database exports where missing values serialize as null
  • Reducing config noise by omitting explicitly-null settings
  • Preparing JSON for merge operations where null should mean absent
  • Shrinking documents before hashing or comparison

Troubleshooting common errors

The API stopped clearing fields after you cleaned the payload

Why: The nulls were merge-patch delete instructions, and stripping them removed the instructions.

Fix: Send the nulls. This is the single most common way this tool causes a real bug.

Array indices no longer line up with another array

Why: Removing nulls from an array compacts it, shifting every later element down.

Fix: Keep nulls in any array whose positions are meaningful, or restructure the parallel arrays into a single array of objects.

Empty strings and empty objects are still there

Why: Correct behaviour - this tool matches `null` exactly and nothing else.

Fix: Use the JSON Remove Empty Values tool if you want those removed too.

A parent object became empty after its only value was removed

Why: The container is retained even when all of its contents were null.

Fix: Run the JSON Remove Empty Values tool afterwards to collapse the now-empty containers.

Limitations

What this tool deliberately does not do, so you know when to reach for something else.

  • Only exact `null` values are removed. Empty strings, empty arrays and empty objects are left alone.
  • Removing nulls changes the meaning of a document wherever the consumer distinguishes null from absent - notably in JSON Merge Patch.
  • Compacting arrays shifts the indices of later elements.
  • Containers left empty by the operation are not themselves removed.
  • The operation is not reversible; the original nulls cannot be reconstructed.

Frequently asked questions

Learn more

Command Palette

Search for a tool or command