DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk3 min

Why “[object Object]” Is Not Valid JSON in JavaScript—and How to Fix It

The error means JSON.parse() received something that is not JSON text. Find out how to check the value and choose the right fix for an object or stored string.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

[object Object] is not a valid JSON usually means your code passed the string representation of a JavaScript object to JSON.parse(). That text is not JSON. Check the value’s type and how it was stored: use an object directly, or serialize a plain object with JSON.stringify() before saving it as text.

What the error means

JSON.parse() expects a string containing valid JSON text. It turns that text into the value it represents; it does not convert an existing JavaScript object into JSON. MDN documents the method and examples of invalid JSON, including single-quoted strings and trailing commas: MDN: JSON.parse().

A plain object commonly becomes the string [object Object] when JavaScript coerces it to text. That string is not JSON, so parsing it fails. The same mismatch can happen when an object is passed straight to JSON.parse() or written directly to Web Storage, which stores strings rather than preserving an object’s structure.

Check the value immediately before parsing

Inspect the exact value and its runtime type where the error occurs:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
console.log(sbs, typeof sbs);

If this value may contain password-reset details or other sensitive data, do not expose it in shared or production logs. Use a safe local debugging environment and avoid logging secrets.

  • If the value is already an object, use it directly; do not parse it.
  • If it is a string, inspect its contents. It may be [object Object] or malformed JSON for another reason.
  • If it came from Web Storage, check the code that wrote it as well as the code that reads it.

Choose the fix that matches the value

The value is already a JavaScript object

Access its properties directly. For example:

const data = { user: { email: "[email protected]" } };
const email = data.user.email;

Calling JSON.parse(data) is incorrect because data is already an object, not JSON text.

You need to store and restore a plain object

Serialize the object before writing it to Web Storage, then parse the retrieved string:

const sessionData = { user: { email: "[email protected]" } };
sessionStorage.setItem("sbsession", JSON.stringify(sessionData));

const sbs = sessionStorage.getItem("sbsession");
const restoredSession = sbs === null ? null : JSON.parse(sbs);

JSON.stringify() converts a JavaScript value into JSON text. MDN documents the method and the Web Storage string behavior, including what happens when a plain object is stored directly: MDN: JSON.stringify() and MDN: Storage.setItem().

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

This is an appropriate round trip for the plain object shown. JSON does not preserve every JavaScript type, and circular references cause serialization to throw, so do not assume every JavaScript value can be safely serialized this way.

The retrieved value is a string, but parsing still fails

Examine the raw string and check its JSON syntax. A value can be a string without being valid JSON: for example, JSON requires double-quoted strings, and a trailing comma can make an otherwise familiar-looking object invalid. The specific error text may differ depending on the engine and malformed input.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How this relates to the SitePoint password-reset thread

In a SitePoint Community thread dated November 11–12, 2023, the poster pointed to sessionData = JSON.parse(sbs), where sbs came from sessionStorage.sbsession. A reply suggested the stored value might have been written as an object without serialization, leaving the text [object Object]. The poster later reported fixing their app by retrieving the user email directly with getItem(): SitePoint Community thread.

That reported fix applies to that app’s flow; it does not mean every similar error should be fixed by bypassing parsing. If the email is stored separately and you need only that value, retrieve the corresponding key directly. If you need to restore the full session object, verify the key and stored value shape, then serialize the object when writing it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.