JSON Stringify in JavaScript

Level 259 keystrokes

JSON.stringify() converts a JavaScript object to a JSON string.

JavaScript code

// Create a simple object with two properties
1let obj = { a: 1, b: 2 };
// JSON.stringify() converts the object to a JSON string
// Useful for storing data or sending to APIs
// Result: '{"a":1,"b":2}'
2console.log(JSON.stringify(obj));

Output

{"a":1,"b":2}
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this JavaScript code and how often they appear.

  • ;× 2
  • :× 2
  • .× 2
  • (× 2
  • )× 2
  • ,× 1
  • {× 1
  • }× 1
  • =× 1

More JavaScript examples at level 2

← JavaScript typing practice