JavaScript - serialize object to json

12 points
Created by:

In JavaScript, it is possible to serialize objects to JSON in the following way.

1. JSON.stringify method example

// ONLINE-RUNNER:browser;

var studentObject = {
    name: 'John',
    age: 25,
    todos: [

var studentJson = JSON.stringify(studentObject);


Note: JSON.stringify method has been introduced in ES5.

See also

  1. JavaScript - deserialize json to object 

Alternative titles

  1. JavaScript - convert JS object to JSON string
  2. JavaScript - converting object to string
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

JavaScript - JSON

Native Advertising
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂