circular JSON JavaScript Origin: On your device OSI layer 6 · Presentation Last updated 13 Oct 2026

TypeError: Converting circular structure to JSON

JSON.stringify met an object that references itself (directly or through children).

Exact message you may see Converting circular structure to JSONcyclic object value
Seen on: JavaScript

Meaning

DOM nodes, framework objects (Express req/res, Mongoose docs), and parent↔child links create cycles that JSON can’t represent.

Common causes

  • Logging/stringifying req/res or DOM elements
  • Parent/child references in your data
  • ORM documents with back-references

⚡ Quick fix

  1. Stringify only the fields you need
  2. Use a replacer that skips seen objects
  3. Use util.inspect or console.dir for logging

Detailed fix by platform

JavaScript

  1. javascript
    const seen = new WeakSet();
    JSON.stringify(obj, (k, v) => (typeof v === 'object' && v !== null ? (seen.has(v) ? undefined : (seen.add(v), v)) : v));

How to diagnose

  1. Object — Which object (the message names the path)?
  2. Need — Do you really need the whole object?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

entity.parse.failed — API Error: Malformed JSON in request body (entity.parse.failed / JSON parse error) (API)entity.parse.failedInvalidDefinitionException — com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class X and no properties discovered (Java)InvalidDefinitionExce…is an invalid start of a value — System.Text.Json: '<' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0 (.NET)is an invalid start o…json_decode null — json_decode() returns null / JSON_ERROR_SYNTAX: Syntax error (PHP)json_decode nullJsonException object cycle — JsonException: A possible object cycle was detected (.NET)JsonException object …MismatchedInputException — com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type `java.util.ArrayList` from Object value (Java)MismatchedInputExcept…not JSON serializable — TypeError: Object of type datetime is not JSON serializable (Python)not JSON serializableOnly plain objects can be passed to Client Components — Next.js: Error: Only plain objects, and a few built-ins, can be passed to Client Components from Server Components. Classes or null prototypes are not supported (Next.js)Only plain objects ca…circular …

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.