JSON stands for JavaScript Object Notation. A JSON object is really a string that has yet to be turned into the object it represents.

To add a property to an existing object in JS you could do the following.

object["property"] = value;

or

object.property = value;

If you provide some extra info like exactly what you need to do in context you might get a more tailored answer.

Answer from Quintin Robinson on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-how-to-add-an-element-to-a-json-object
Adding Elements to a JSON Object in JavaScript - GeeksforGeeks
January 17, 2026 - let jsonObject = { key1: 'value1', key2: 'value2' }; jsonObject.newKey = 'newValue'; console.log(jsonObject); ... Bracket notation allows adding properties to a JSON object using dynamic or non-standard keys.
🌐
Educative
educative.io › answers › how-to-add-data-to-a-json-file-in-javascript
How to add data to a JSON file in JavaScript
Write the updated JavaScript object back to the JSON file using the writeFileSync() method as follows: fs.writeFileSync('data.json', JSON.stringify(jsonData)); Let's run the following widget and update the record of the data.json file by adding ...
🌐
Tutorial Republic
tutorialrepublic.com › faq › how-to-add-new-property-to-json-object-using-javascript.php
How to Add New Property to JSON Object Using JavaScript
Let's take a look at the following ... + "<br>"); // Prints: United States // Converting JS object back to JSON string json = JSON.stringify(obj); document.write(json);...
🌐
EyeHunts
tutorial.eyehunts.com › home › how to add json object to another json object in javascript | example code
How to add JSON object to another JSON object in JavaScript
November 18, 2022 - And use the push() method to add a JSON array at end of an array. ... <!DOCTYPE html> <html> <body> <script type="text/javascript"> const original = { "product": { "prodId": "PROD100" }, "pkgs": { "pkgId": "PKG137" }, "discount": "50", "pFrom": ...
🌐
TutorialsPoint
tutorialspoint.com › article › how-to-add-an-element-to-a-json-object-using-javascript
How to add an element to a JSON object using JavaScript?
February 16, 2023 - var jsonObject = { members: { host: "hostName", viewers: { userName1: "userData1", userName2: "userData2" } } }; console.log("Original JSON object:"); console.log(jsonObject); console.log("\nAdding an element using bracket notation:"); jsonObject.members.viewers['userName3'] = 'userData3'; console.log("\nJSON object after adding property:"); console.log(jsonObject);
🌐
W3Schools
w3schools.com › js › js_json.asp
JavaScript JSON
JavaScript has a built in function for converting JSON strings into JavaScript objects: ... You can receive pure text from a server and use it as a JavaScript object. You can send a JavaScript object to a server in pure text format.
Find elsewhere
🌐
Jsdiaries
jsdiaries.com › how to add an array element to json object in javascript.
How to add an array element to JSON object in JavaScript. | The JavaScript Diaries
This is done by using the JavaScript native methods .parse()and .stringify() ... Use stringify() to convert it back to its original format. Let’s take the following JSON string data as an example: '{"characters":[{"name":"Tommy Vercetti",...
🌐
GeeksforGeeks
geeksforgeeks.org › javascript-how-to-add-an-element-to-a-json-object
How to Add an Element to a JSON Object using JavaScript? | GeeksforGeeks
August 27, 2024 - In JavaScript to add an element to a JSON object by simply assigning a value to a new key.
🌐
Quora
quora.com › I-want-to-add-a-new-JSON-object-to-the-already-existing-JSON-Array-What-are-some-suggestions
I want to add a new JSON object to the already existing JSON Array. What are some suggestions? - Quora
Answer (1 of 5): Simply use push method of Arrays. [code]var data = [ { name: "Pawan" }, { name: "Goku" }, { name: "Naruto" } ]; var obj = { name: "Light" }; data.push(obj); console.log(data); /* 0:{name:"Pawan"} 1:{name: "Goku"} 2:{name: "Naruto"} ...
🌐
GeeksforGeeks
geeksforgeeks.org › node.js › how-to-add-data-in-json-file-using-node-js
How to Add Data in JSON File using Node.js ? - GeeksforGeeks
July 23, 2025 - Now that we have a JSON file to write to, first we will make a JavaScript object to access the file.For this, we will use · fs.readFileSync() which will give us the data in raw format. To get the data in JSON format, we will use · JSON.parse().Thus, the code on our server side will look like this: var data = fs.readFileSync('data.json'); var myObject= JSON.parse(data); Now that we have our object ready, let's suppose we have a key-value pair of data that we want to add :
🌐
SitePoint
sitepoint.com › javascript
Adding items to a JSON object - JavaScript - SitePoint Forums | Web Development & Design Community
March 3, 2009 - Does anyone know the function for adding more items to an already declared JSON object · Not correct!! The line event[i] is wrong. When i send ‘events’ to console i get something this - iterating over a numer of variables and adding their values to the JSON object: · I reckon the object ...
🌐
Quora
quora.com › How-do-you-add-elements-to-a-JSON-Array
How to add elements to a JSON Array - Quora
So, first off, JSON arrays are those square-bracket lists of stuff, right? Like `["apple", "banana"]`. To add something, you gotta think about *how* you’re doing it. Yet... If you’re coding in JavaScript, say, you’d probably start with an array, use `.push("orange")` to slap it on the end, then turn it back into JSON with `JSON.stringify()`. Easy peasy.
Top answer
1 of 6
303

JSON is just a notation; to make the change you want parse it so you can apply the changes to a native JavaScript Object, then stringify back to JSON

var jsonStr = '{"theTeam":[{"teamId":"1","status":"pending"},{"teamId":"2","status":"member"},{"teamId":"3","status":"member"}]}';

var obj = JSON.parse(jsonStr);
obj['theTeam'].push({"teamId":"4","status":"pending"});
jsonStr = JSON.stringify(obj);
// "{"theTeam":[{"teamId":"1","status":"pending"},{"teamId":"2","status":"member"},{"teamId":"3","status":"member"},{"teamId":"4","status":"pending"}]}"
2 of 6
29
var Str_txt = '{"theTeam":[{"teamId":"1","status":"pending"},{"teamId":"2","status":"member"},{"teamId":"3","status":"member"}]}';

If you want to add at last position then use this:

var parse_obj = JSON.parse(Str_txt);
parse_obj['theTeam'].push({"teamId":"4","status":"pending"});
Str_txt = JSON.stringify(parse_obj);
Output //"{"theTeam":[{"teamId":"1","status":"pending"},{"teamId":"2","status":"member"},{"teamId":"3","status":"member"},{"teamId":"4","status":"pending"}]}"

If you want to add at first position then use the following code:

var parse_obj = JSON.parse(Str_txt);
parse_obj['theTeam'].unshift({"teamId":"4","status":"pending"});
Str_txt = JSON.stringify(parse_obj);
Output //"{"theTeam":[{"teamId":"4","status":"pending"},{"teamId":"1","status":"pending"},{"teamId":"2","status":"member"},{"teamId":"3","status":"member"}]}"

Anyone who wants to add at a certain position of an array try this:

parse_obj['theTeam'].splice(2, 0, {"teamId":"4","status":"pending"});
Output //"{"theTeam":[{"teamId":"1","status":"pending"},{"teamId":"2","status":"member"},{"teamId":"4","status":"pending"},{"teamId":"3","status":"member"}]}"

Above code block adds an element after the second element.

🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Learn_web_development › Core › Scripting › JSON
Working with JSON - Learn web development | MDN
we retrieve the response as JSON using the json() function of the Response object. Note: The fetch() API is asynchronous. You can learn about asynchronous functions in detail in our Asynchronous JavaScript module, but for now, we'll just say that we need to add the keyword async before the name of the function that uses the fetch API, and add the keyword await before the calls to any asynchronous functions.
🌐
freeCodeCamp
forum.freecodecamp.org › javascript
How to add a key/value pair to an existing json file? - JavaScript - The freeCodeCamp Forum
September 8, 2023 - The Json file would look some like this: { “data”: [ { "id": "1700148573403304137", "text": "Hi ! " }, { "id": "1700147255322259501", "text": "Hello" } ] For the final I want to add something like: “te…
🌐
JavaScript.info
javascript.info › tutorial › the javascript language › data types
JSON methods, toJSON
JavaScript provides methods JSON.stringify to serialize into JSON and JSON.parse to read from JSON.