JSON is a text format; a JavaScript object is a value living in your program's memory. JSON looks like an object literal, but it has stricter rules: keys and strings need double quotes, and values can only be strings, numbers, booleans, null, arrays and objects. You move between the two with JSON.parse and JSON.stringify, and anything JSON can't express gets dropped or changed on the way.
JSON vs JavaScript object at a glance
The JSON vs JavaScript object difference comes down to text versus a value. MDN's JSON reference puts it plainly: JSON is based on JavaScript syntax, but most of JavaScript is not JSON.
| JSON | JavaScript object | |
|---|---|---|
| What it is | A string of text | A value in memory |
| Keys | Double-quoted strings only | Quoted, unquoted, computed or Symbols |
| Strings | Double quotes only | Single, double or backticks |
| Values | String, number, boolean, null, array, object | Anything, including functions, Dates, Maps |
undefined, NaN, Infinity |
Not allowed | Allowed |
| Comments and trailing commas | Not allowed | Allowed |
| Methods | No | Yes |
| Used by | Any language | JavaScript only |
JSON is text, an object is a value
JSON is always a string until something parses it. When fetch gives you a response body, a file, or a localStorage value, you're holding JSON text, and response.json() or JSON.parse turns it into an object.
The JSON standard, RFC 8259, calls JSON a lightweight, text-based, language-independent data interchange format. It was derived from JavaScript's object literals, hence the resemblance, but a Python or Go server reads the same JSON without knowing any JavaScript.
An object can hold references, methods and a prototype. None of that has a text form, which is why the round trip below loses data.
Syntax rules JSON adds on top of object literals
JSON's syntax rules are stricter than an object literal's on keys, quotes and numbers. MDN's object initializer page says JSON only allows the "property": value form: no shorthand properties and no computed names.
Valid JavaScript, invalid JSON:
{ name: 'Ada', role: 'admin', }
Valid JSON:
{ "name": "Ada", "role": "admin" }
The rules that trip people up most:
- Keys must be double-quoted strings.
- Strings must use double quotes, never single quotes or backticks.
- No trailing commas, and no comments.
- Numbers can't have leading zeros, a decimal point needs a digit after it, and
NaNandInfinityaren't allowed. - Whitespace is limited to tab, carriage return, line feed and space.
Here's the error Node.js gave me for the single-quoted version:
JSON.parse("{name: 'Ada'}")
SyntaxError: Expected property name or '}' in JSON at position 1 (line 1 column 2)
There's more on the quote rule in why JSON requires double quotes, and on the missing comments in can JSON have comments.
What survives a round trip through JSON
A round trip through JSON.stringify and JSON.parse keeps plain data and quietly changes everything else. I ran this object through both in Node.js:
const user = {
name: "Ada",
tags: new Set(["admin"]),
joined: new Date(Date.UTC(2026, 0, 2)),
score: NaN,
nickname: undefined,
greet() {},
};
JSON.stringify(user);
// {"name":"Ada","tags":{},"joined":"2026-01-02T00:00:00.000Z","score":null}
Four of the six properties changed or vanished:
| Property | In the object | In the JSON | After JSON.parse |
|---|---|---|---|
name |
"Ada" |
"Ada" |
"Ada" |
tags |
A Set | {} |
Empty object |
joined |
A Date | ISO string | Still a string |
score |
NaN |
null |
null |
nickname |
undefined |
Gone | Gone |
greet |
A method | Gone | Gone |
That's what the JSON.stringify docs promise. Functions, undefined and Symbols are left out of objects and turned into null in arrays. NaN and Infinity become null. Map and Set become {}, and a Date goes through its toJSON() method as an ISO string. A BigInt doesn't get converted at all: JSON.stringify({ id: 10n }) threw Do not know how to serialize a BigInt in my test.
The Date row causes the most bugs. joined.getFullYear() works before the round trip and throws after it, because joined is now a string. My post on storing dates in JSON covers how to parse them back.
The proto key: same text, different result
The same text can mean different things as a literal and as JSON, and __proto__ is the clearest case. MDN notes that in JSON, "__proto__" is a normal key, while in an object literal it sets the object's prototype.
I checked both in Node.js:
const literal = { "__proto__": { admin: true } };
literal.admin; // true (inherited from the prototype)
Object.keys(literal); // []
const parsed = JSON.parse('{"__proto__": {"admin": true}}');
parsed.admin; // undefined
Object.keys(parsed); // ["__proto__"]
JSON.parse treats the key as plain data, the safe choice for outside text. Trouble starts when a naive deep merge later copies that object into another one. That's how prototype pollution bugs begin. Filter __proto__ keys before merging untrusted JSON.
Is JSON a subset of JavaScript?
JSON is now a subset of JavaScript, but only since ES2019. Before that, JSON strings could contain two characters, U+2028 and U+2029, that were a syntax error in JavaScript string literals.
The JSON superset proposal fixed this by allowing them in JavaScript strings, and V8 shipped it in Chrome 66. The reverse was never true: most object literals are not valid JSON.
Which one should you use?
Use objects inside your code and JSON at the edges. Once data leaves your process, for a server, a file or localStorage, design it for what JSON can hold. Store dates as ISO strings, sets as arrays and big IDs as strings on purpose, before a round trip makes the choice for you.
The catch: JSON can't describe types. A string that looks like a date is just a string. If you need real types back, you need a schema, a reviver function in JSON.parse, or a library on top.
When a payload won't parse, a JSON validator points at the line and column of the first error. For the two conversion methods themselves, see JSON.stringify vs JSON.parse, and for fields that disappear, why JSON.stringify drops fields.
FAQ
Is JSON a JavaScript object?
No. JSON is a string of text that follows a fixed format. JSON.parse turns that text into a JavaScript object, and JSON.stringify turns an object back into JSON text.
Can a JavaScript object literal be pasted in as JSON?
Only if it follows JSON's rules: double-quoted keys and strings, no trailing commas, no comments, and no functions or undefined. Most hand-written object literals break at least one of these.
Is JSON only for JavaScript?
No. JSON was derived from JavaScript object literals, but it is language-independent. Python, Go, Java and almost every other language read and write it.
Why does my Date become a string after JSON.parse?
JSON has no date type. JSON.stringify writes a Date as an ISO string, and JSON.parse leaves it as a string. You have to convert it back with new Date() yourself.