var json = { ... };
var key = "foo";
delete json[key]; // Removes json.foo from the dictionary.

You can use splice to remove elements from an array.

Answer from dteoh on Stack Overflow
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ remove-json-element-javascript
Remove json element - JavaScript?
November 3, 2023 - Use the delete keyword to remove a specific property from a JSON object:
๐ŸŒ
Medium
medium.com โ€บ knowledge-pills โ€บ how-do-i-remove-a-property-from-a-json-object-fd7ec14d37bd
How to remove a property from a JSON object? | by Fuji Nguyen | Knowledge Pills | Medium
January 8, 2024 - Here is an example of how to use the delete operator to remove the property age from a JSON object: let obj = { name: "John", age: 30, occupation: "developer" }; delete obj.age; console.log(obj); // Output: { name: "John", occupation: "developer" ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ javascript โ€บ how-to-remove-element-from-json-object-in-javascript
JSON File Remove Operations in Node.js - GeeksforGeeks
January 17, 2026 - The delete keyword removes a specific property from a JSON object, and the updated structure can be verified using the console. Removes a key-value pair directly from the object.
Top answer
1 of 7
128

delete operator is used to remove an object property.

delete operator does not returns the new object, only returns a boolean: true or false.

In the other hand, after interpreter executes var updatedjsonobj = delete myjsonobj['otherIndustry']; , updatedjsonobj variable will store a boolean value.

How to remove Json object specific key and its value ?

You just need to know the property name in order to delete it from the object's properties.

delete myjsonobj['otherIndustry'];

let myjsonobj = {
  "employeeid": "160915848",
  "firstName": "tet",
  "lastName": "test",
  "email": "[email protected]",
  "country": "Brasil",
  "currentIndustry": "aaaaaaaaaaaaa",
  "otherIndustry": "aaaaaaaaaaaaa",
  "currentOrganization": "test",
  "salary": "1234567"
}
delete myjsonobj['otherIndustry'];
console.log(myjsonobj);

If you want to remove a key when you know the value you can use Object.keys function which returns an array of a given object's own enumerable properties.

let value="test";
let myjsonobj = {
      "employeeid": "160915848",
      "firstName": "tet",
      "lastName": "test",
      "email": "[email protected]",
      "country": "Brasil",
      "currentIndustry": "aaaaaaaaaaaaa",
      "otherIndustry": "aaaaaaaaaaaaa",
      "currentOrganization": "test",
      "salary": "1234567"
}
Object.keys(myjsonobj).forEach(function(key){
  if (myjsonobj[key] === value) {
    delete myjsonobj[key];
  }
});
console.log(myjsonobj);

2 of 7
22

There are several ways to do this, lets see them one by one:

  1. delete method: The most common way

const myObject = {
    "employeeid": "160915848",
    "firstName": "tet",
    "lastName": "test",
    "email": "[email protected]",
    "country": "Brasil",
    "currentIndustry": "aaaaaaaaaaaaa",
    "otherIndustry": "aaaaaaaaaaaaa",
    "currentOrganization": "test",
    "salary": "1234567"
};

delete myObject['currentIndustry'];
// OR delete myObject.currentIndustry;
  
console.log(myObject);

  1. By making key value undefined: Alternate & a faster way:

let myObject = {
    "employeeid": "160915848",
    "firstName": "tet",
    "lastName": "test",
    "email": "[email protected]",
    "country": "Brasil",
    "currentIndustry": "aaaaaaaaaaaaa",
    "otherIndustry": "aaaaaaaaaaaaa",
    "currentOrganization": "test",
    "salary": "1234567"
  };

myObject.currentIndustry = undefined;
myObject = JSON.parse(JSON.stringify(myObject));

console.log(myObject);

  1. With es6 spread Operator:

const myObject = {
    "employeeid": "160915848",
    "firstName": "tet",
    "lastName": "test",
    "email": "[email protected]",
    "country": "Brasil",
    "currentIndustry": "aaaaaaaaaaaaa",
    "otherIndustry": "aaaaaaaaaaaaa",
    "currentOrganization": "test",
    "salary": "1234567"
};


const {currentIndustry, ...filteredObject} = myObject;
console.log(filteredObject);

Or if you can use omit() of underscore js library:

const filteredObject = _.omit(currentIndustry, 'myObject');
console.log(filteredObject);

When to use what??

If you don't wanna create a new filtered object, simply go for either option 1 or 2. Make sure you define your object with let while going with the second option as we are overriding the values. Or else you can use any of them.

hope this helps :)

๐ŸŒ
Tech Solution Stuff
techsolutionstuff.com โ€บ post โ€บ how-to-remove-specific-json-object-from-array-javascript
How To Remove Specific JSON Object From Array Javascript
March 29, 2024 - const arr = [ {id: "1", name: "car", type: "vehicle"}, {id: "2", name: "bike", type: "vehicle"}, {id: "3", name: "cycle", type: "vehicle"}, {id: "4", name: "red", type: "color"}, {id: "5", name: "green", type: "color"}, {id: "6", name: "blue", type: "color"}, ]; const removeById = (arr, id) => { const requiredIndex = arr.findIndex(el => { return el.id === String(id); }); if(requiredIndex === -1){ return false; }; return !!arr.splice(requiredIndex, 1); }; removeById(arr, 5); console.log(arr); ... [ {id: "1", name: "car", type: "vehicle"}, {id: "2", name: "bike", type: "vehicle"}, {id: "3", name: "cycle", type: "vehicle"}, {id: "4", name: "red", type: "color"}, {id: "6", name: "blue", type: "color"}, ] ... I'm a software engineer and the founder of techsolutionstuff.com. Hailing from India, I craft articles, tutorials, tricks, and tips to aid developers.
Find elsewhere
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ how-to-delete-an-index-from-json-object
How to delete an index from JSON Object ? | GeeksforGeeks
September 13, 2024 - Syntax for splice() function: array.splice(indexno, noofitems(n), item-1, item-2, ..., item-n) Exam ... In JSON, empty objects can cause data inconsistency and processing issues. We will explore three different approaches filter method, forEach Loop, and for Loop to remove empty objects from JSON in JavaScript.Table of ContentUsing filter MethodUsing forEach LoopUsing for LoopUsing Array.reduce() Meth
๐ŸŒ
Pluralsight
pluralsight.com โ€บ tech insights & how-to guides โ€บ tech guides & tutorials
Delete Data from JSON Using a Key in React | Pluralsight
November 9, 2020 - This guide explains the steps to parse JSON data and perform the delete operation on a nested JSON object using a key as input.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ javascript-remove-a-json-attribute
JavaScript | Remove a JSON attribute | GeeksforGeeks
August 11, 2023 - In this article, we will see how to remove a JSON attribute from the JSON object. To do this, there are few of the mostly used techniques discussed. First delete property needs to be discussed. ... This keyword deletes both the value of the property and the property itself. After deletion, the property is not available for use before it is added back again. This operator is created to be used on object properties, not on variables or functions. This operator should not be used on predefined JavaScript object properties.
๐ŸŒ
Subinsb
subinsb.com โ€บ js-remove-item-from-json-array-variables
Delete Items From JSON or Remove Variables in JavaScript - Subin's Blog
April 13, 2014 - In PHP, you can directly remove an item from an array using unset function. But there is no unset function in JavaScript. But there is another function that will remove a variable. Itโ€™s called delete. Removing variables isnโ€™t the only thing it does. It can also remove items from a JSON array in JavaScript.
๐ŸŒ
ASPSnippets
aspsnippets.com โ€บ questions โ€บ 254478 โ€บ Remove-item-from-JSON-object-Array-using-JavaScript-and-jQuery
Remove item from JSON object Array using JavaScript and jQuery
November 22, 2018 - <script type="text/javascript"> function RemoveItems(index) { var customers = [{ CustomerId: 1, Name: "John Hammond", Country: "United States" }, { CustomerId: 2, Name: "Mudassar Khan", Country: "India" }, { CustomerId: 3, Name: "Suzanne Mathews", Country: "France" }, { CustomerId: 4, Name: "Robert Schidner", Country: "Russia"}]; // Remove item from specified index.
๐ŸŒ
Quora
quora.com โ€บ How-do-I-remove-a-few-fields-from-the-JSON-array-response-using-JavaScript
How to remove a few fields from the JSON array response using JavaScript - Quora
JavaScript (programming l... ... To remove specific fields from each object in a JSON array using JavaScript, transform the array with a mapping that creates new objects excluding the unwanted keys.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ removing-property-from-a-json-object-in-javascript
Removing property from a JSON object in JavaScript
<!DOCTYPE html> <html> <head> <title>Deleting property of an JSON object.</title> </head> <body> <p id="para"></p> <script> var Cricketer = { 'name': "Dhoni", 'role': "Keeper-batsmen", 'age': 41, 'bat': "Right", }; delete Cricketer.role; document.getElementById("para").innerHTML = Cricketer.name + " age" + " is " + Cricketer.role; </script> </body> </html> ... The Destructing assignment is a syntax in JavaScript expression, which will expand the values from arrays or the properties of an object into distinct variables.
๐ŸŒ
Sentry
sentry.io โ€บ sentry answers โ€บ javascript โ€บ removing properties from objects in javascript
Removing Properties from Objects in JavaScript | Sentry
July 6, 2022 - Use the delete operator to remove a property from an object. let person = { firstName: "John", lastName: "Doe", gender: "Male", age: 34 }; // Delete the age property first delete person.age; let json = JSON.stringify(person); console.log(json);
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ how-to-remove-specific-json-object-from-array-javascript
How To Remove Specific JSON Object From Array JavaScript? | GeeksforGeeks
April 18, 2024 - Once a property is deleted, it no longer exists in the object.Using delete OperatorThe basic method to remove a property from a JavaScript object i ... In JavaScript, the array of objects can be JSON stringified for easy data interchange and storage, enabling handling and transmission of structured data.