var obj = JSON.parse(string);

Where string is your json string.

Answer from Kshitij on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › JSON › parse
JSON.parse() - JavaScript | MDN
The JSON.parse() static method parses a JSON string, constructing the JavaScript value or object described by the string. An optional reviver function can be provided to perform a transformation on the resulting object before it is returned.
🌐
JSONLint
jsonlint.com › json-stringify
JSON Stringify - Escape JSON for Embedding | JSONLint | JSONLint
While URL encoding is usually better, sometimes you need to pass JSON as a query parameter. Stringifying is the first step. These terms are often used interchangeably, but technically: JSON.stringify() — Converts a JavaScript object to a JSON string
🌐
Reddit
reddit.com › r/learnjavascript › creating an object string without using json.stringify
r/learnjavascript on Reddit: creating an object string without using JSON.stringify
September 2, 2021 -

In order to better understand how JSON.stringify works, I've been tasked with creating a function that can take either an array or an object literal and convert either one into a string. For example:

[10000, "kani"] -->  " [10000,"kani"] "
{ a: "is for apple" } -->  " {"a":"is for apple"} " 
{ foo: true, bar: false, baz: null } --> "{"foo":true,"bar":false,"baz": null}"

Also, the object keys need to be in quotation marks too. I've been wracking my brain trying think of a strategy and cannot come up with anything. I've tried using the reduce method, and was able to surround the keys with quotations using template literal syntax for some test cases but not all. And I can't figure out how to set the entire object, which is my accumulator, to either an object string '{ }' or an array string '[ ]' and still be able to update the value of accumulator as reduce iterates. Here's the code I've tried:

function stringMaker(input) {

input = Object.entries(input).reduce((accum, element) => { 
let [key, value] = element; 
accum["${key}"] = value;  
return accum; 
}, { } ); 
return input; 
}

const object1 = {a: 'is for apple'};
console.log(stringMaker(object1)) --> {"a": 'is for apple'} //no quotation marks

const object2 = { foo: true, bar: false, baz: null }
console.log(stringMaker(object2)) --> {"foo": true, "bar": false, "baz": null} //no quotation marks

const object3 = {a:{"b":"c"}}
console.log(stringMaker(object3)) --> Object({ "a": Object({ b: 'c' }) }) --> expected '{"a":{"b":"c"}}' 
//I have no idea what happened here

As you can see my results are all over the place. I don't even know why the last case is returning Object. And I haven't even started testing with arrays yet. Advice/hints please!

🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › JSON › stringify
JSON.stringify() - JavaScript | MDN
The JSON.stringify() static method converts a JavaScript value to a JSON string, optionally replacing values if a replacer function is specified or optionally including only the specified properties if a replacer array is specified.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Learn_web_development › Core › Scripting › JSON
Working with JSON - Learn web development | MDN
Many programming environments feature the ability to read (parse) and generate JSON. In JavaScript, the methods for parsing and generating JSON are provided by the JSON object. Note: Converting a string to a native object is called deserialization, while converting a native object to a string so it can be transmitted across the network is called serialization.
🌐
W3Schools
w3schools.com › js › js_json_parse.asp
JSON.parse()
A common use of JSON is to exchange data to/from a web server. When receiving data from a web server, the data is always a string. Parse the data with JSON.parse(), and the data becomes a JavaScript object.
Find elsewhere
🌐
Pluralsight
pluralsight.com › tech insights & how-to guides › tech guides & tutorials
Convert Strings to JSON Objects in JavaScript with eval() | Pluralsight
March 31, 2025 - The array of objects is now converted to JSON, and it can be sent over to the server to pass the request as a JSON file format using the stringify() function. The eval() function in JavaScript is used to take an expression and return the string.
🌐
DigitalOcean
digitalocean.com › community › tutorials › js-json-parse-stringify
How To Use JSON.parse() and JSON.stringify() | DigitalOcean
November 24, 2021 - The JSON object, available in all modern browsers, has two useful methods to deal with JSON-formatted content: parse and stringify. JSON.parse() takes a JSON string and transforms it into a JavaScript object.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-create-json-string-in-javascript
How to Create JSON String in JavaScript? - GeeksforGeeks
July 23, 2025 - Below are the following approaches to creating a JSON string: ... We can directly convert a Javascript object to a JSON string using the JSON.stringify( ) method where we pass the object as an argument.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-convert-json-to-string-in-javascript
How to Convert JSON to string in JavaScript ? - GeeksforGeeks
July 23, 2025 - In this approach, using JSON.stringify() in JavaScript, specifying optional parameters for indentation to format JSON data into a more readable and structured string representation for debugging or visualization.
🌐
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.
🌐
JSON
json.org
JSON
JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others.
🌐
freeCodeCamp
freecodecamp.org › news › json-stringify-example-how-to-parse-a-json-object-with-javascript
JSON Stringify Example – How to Parse a JSON Object with JS
January 5, 2021 - Luckily, this works the same way as in the browser – just use JSON.stringify() to convert JavaScript object literals or arrays into a JSON string:
🌐
Jsontostring
jsontostring.com
Convert JSON to String Online
Convert JSON to String Online with our tool. Our Javascript Object to String Converter can convert multiline content with full accuracy online.
🌐
Reddit
reddit.com › r/learnprogramming › converting a string to json javascript
r/learnprogramming on Reddit: Converting a string to JSON javascript
March 2, 2019 -

I know this is simple with `JSON.parse()` but that will not seem to work in my case. I think the issue is that `JSON.parse()` works only when the object is in the format of `{"key": "value"}` not in a `{key: "value"}` like I have. Below is a copy of the string that needs to be converted to JSON along with the error message.

{ ignoreSSLError: false,

username: null,

_id: 5c7abe63087bd40ff8439fec,

createdAt: 2019-03-02T17:33:23.312Z,

__v: 0 }

SyntaxError: Unexpected token i in JSON at position 2

Suggestions on how I can fix this? Changing the initial string is not an option. That is how it gets pulled fro AWS SQS, I wish it was that easy.

🌐
HostingAdvice
hostingadvice.com › home › how-to
JavaScript "Object to String" Using JSON.stringify()
March 24, 2023 - JSON.parse() parses a string as JSON, so it will take in a string value and output a JSON value. Ergo, it’s the opposite of JSON.stringify(). That’s enough stringification fun for now.