JSON Filter / Pick Keys

Keep or remove specific keys from a JSON object. Supports dot notation for nested fields.

Mode:
Only the specified keys will be kept in the output.

Keep Mode vs Remove Mode

Keep mode — only the keys you specify are retained in the output. Every other key is discarded. This is useful when you want to extract a subset of fields, e.g. returning only name, email, age from a large user object.

Remove mode — only the keys you specify are deleted. All other keys survive unchanged. This is useful for stripping sensitive or noisy fields before logging or sharing data, e.g. removing password, token, lastLogin.

Dot notation for nested keys — use a dot to target fields inside nested objects. address.city keeps or removes only the city field inside the address object, leaving other nested fields intact. Arrays of objects are also supported — the filter is applied to every element in the array.

Examples

Input JSON (abridged)Keep: name, address.cityRemove: password, createdAt
{"name":"Ravi","email":"ravi@example.com","password":"secret","address":{"city":"Ahmedabad","pin":"380015"},"createdAt":"2024-01-10"}{"name":"Ravi","address":{"city":"Ahmedabad"}}{"name":"Ravi","email":"ravi@example.com","address":{"city":"Ahmedabad","pin":"380015"}}

In Keep mode with keys name, address.city: only name and the nested address.city survive. In Remove mode with keys password, createdAt: those two fields are deleted and everything else is preserved.

Where Key Filtering Helps

  • Redacting sensitive fields before loggingStrip password, token, ssn or creditCard before writing a request/response to application logs.
  • Trimming a payload for a frontendSend only the fields a UI actually needs instead of the full backend model.
  • Sanitizing data for a support ticketRemove customer PII before pasting a JSON payload into a bug report or Slack thread.
  • Building a smaller test fixtureKeep only the fields relevant to the test case, dropping noise that makes fixtures hard to read.

Filtering Keys in Code

JavaScript — keep mode:

js
function pick(obj, keys) {
  const out = {};
  for (const key of keys) {
    const value = key.split(".").reduce((acc, k) => acc?.[k], obj);
    if (value !== undefined) out[key.split(".").pop()] = value;
  }
  return out;
}

Python — remove mode:

python
def omit(obj: dict, keys: list[str]) -> dict:
    return {k: v for k, v in obj.items() if k not in keys}

Frequently Asked Questions

Yes — if you paste a JSON array, the keep/remove filter is applied independently to every element, so you get back an array with the same filtering rule applied to each item.

In Keep mode, a key that doesn't exist simply doesn't appear in the output — no error is raised. In Remove mode, a nonexistent key is silently ignored since there's nothing to delete.

Yes — dot notation supports any depth, not just one level. a.b.c targets the c field inside b inside a.

No. The tool produces a new filtered document; your input is left untouched so you can compare before and after.

No. Filtering runs entirely in your browser — nothing is sent to a server.

Related Tools