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.
Discussions

creating an object string without using JSON.stringify
There is currently nothing in your code which would surround the value with double quotes; you destructure the value and then just assign it to the double-quoted key in your accumulator object. Also I assume this is a typo? accum["${key}"] Template literal strings require backticks. If you're trying to replicate JSON.stringify you're going to have to get a good understanding of how different types of value get serialised, and think about how you can differentiate them in your code. More on reddit.com
🌐 r/learnjavascript
4
1
September 2, 2021
javascript - Convert JS object to JSON string - Stack Overflow
JSON.stringify(value, replacer, space) value any JavaScript value, usually an object or array. replacer an optional parameter that determines how object values are stringified for objects. It can be a function or an array of strings. space an optional parameter that specifies the indentation of nested structures. If it is omitted, the text will be packed without extra whitespace. If it is a number, it will specify the number of spaces to ... More on stackoverflow.com
🌐 stackoverflow.com
Converting a string to JSON javascript
If you're wondering about the "why" of your issue, JSON.parse doesn't work because key: "value" is not valid JSON. Keys must always be encapsulated in a string. What you're receiving appears to just be pure JavaScript of an object. More on reddit.com
🌐 r/learnprogramming
25
2
March 2, 2019
Is it possible to compress JSON to a string of safe characters that can be used in a URL query string?

Yes. Though be careful of URL length limits some older browsers and proxy servers will impose.

More on reddit.com
🌐 r/javascript
31
18
November 29, 2014
🌐
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.
🌐
W3Schools
w3schools.com › js › js_json_stringify.asp
JSON.stringify()
Use the JavaScript function JSON.stringify() to convert it into a string.
🌐
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.
Find elsewhere
🌐
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.
🌐
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 values have been transformed to uppercase characters. JSON.stringify() takes a JavaScript object and transforms it into a JSON string.
🌐
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
JSON - JavaScript Object Notation. JSON - for storing and exchanging data. Make use of our Json to String Online Converter tool which brings the desired solution in minutes. If you have a huge set of content to be converted into a string, our tool can make your work easier!
🌐
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.