Documentation

Student-friendly HTML, CSS, and JavaScript reference with examples

Sections

JSON.stringify()

Converts a JavaScript object to a JSON string for sending to servers.

const user = { name: 'Alice', age: 25 };
const jsonString = JSON.stringify(user);
// jsonString is '{"name":"Alice","age":25}'

When to use:

  • Sending data with fetch() POST requests
  • Storing objects in localStorage