Remove null values from JSON

Remove null values from JSON objects and arrays, with optional cleanup of empty containers.

freeworks offlinenothing uploaded
ToolJSON Remove Nulls
Input
Output
Put this on your own site

The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.

Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.

Preview

How it works

The parsed value is walked recursively; null object properties and array elements are removed, while optional flags also remove empty strings, arrays, or objects. The cleaned value is serialized with the chosen indentation and removals are counted.

  • Nulls are removed by default while empty strings remain meaningful.
  • Two-space output keeps the cleaned document readable.

Worked example

Clean Nulls
Remove null values from a user profile object
Input
											{"name": "Alice", "email": null, "age": 30, "phone": null}
										
Output
												{
  "name": "Alice",
  "age": 30
}
											

When to use this

API sanitization, fixture cleanup, and export preparation remove absent values.

Edge cases

  • A null array element is removed and later indexes shift.
  • An empty string stays unless its option is enabled.
  • Removing the last child can remove its parent when empty-container options are enabled.

References