Object to JSON String and Back: Serialize and Deserialize Explained
Programmers say "serialize" and "deserialize" all the time. The ideas are simple. An object lives in your program's memory. You cannot save it to a file or send it over the internet as it is. So you turn it into text. That is serializing. Turning the text back into an object is deserializing.
In JavaScript
const user = { name: "Asha", age: 30 };
const text = JSON.stringify(user); // '{"name":"Asha","age":30}'
const back = JSON.parse(text); // { name: "Asha", age: 30 }
In Python the same jobs are json.dumps() and json.loads().
What JSON can hold
JSON understands strings, numbers, true and false, null, arrays and objects. Nothing else. That has some side effects when you stringify:
- Dates become plain text.
- Functions and
undefinedvalues are dropped. NaNand Infinity become null.
Common errors
Most "Unexpected token" errors come from the text not being real JSON. JSON is stricter than a JavaScript object. Keys must have double quotes. Single quotes are not allowed. Trailing commas are not allowed. Comments are not allowed.
The double-encoded string
Sometimes you parse a string and get another string back. This happens when the data was stringified twice. Parse it a second time and it becomes an object. Our tool detects this and tells you.
Pretty or small?
For reading, add spaces: JSON.stringify(obj, null, 2). For sending over a network, keep it small with no spaces.
Check it with a tool
Paste your object into the Object / JSON String converter on the Developer Converters page. It accepts normal JSON and also JavaScript-style objects with single quotes and unquoted keys, then gives you clean JSON. If the text is broken, it points to the line and column of the problem, so you do not have to hunt for a missing bracket.
Everything runs in your browser, so your data is not sent anywhere.
Frequently asked questions
What is the difference between a JavaScript object and JSON?
An object is live data in memory. JSON is text that describes data in a strict format: keys in double quotes, no trailing commas, no functions or comments. JSON.stringify turns an object into JSON text and JSON.parse turns it back.
Why do I get "Unexpected token" when parsing JSON?
The text is not valid JSON. Common causes are single quotes, a trailing comma, an unquoted key, or an HTML error page returned instead of JSON. Our JSON converter also accepts JavaScript-style objects and shows the clean version.
How do I pretty print JSON?
Use JSON.stringify(value, null, 2), which adds line breaks and two-space indents. Remove the spaces again for sending over a network, where smaller is better.
What happens to dates in JSON?
JSON has no date type, so dates become text such as "2026-10-24T09:00:00.000Z". After parsing, turn that text back into a date with new Date(text).
Open the free Developer Converters. It runs in your browser, so nothing is uploaded.