TypeError: Converting circular structure to JSON
JSON.stringify met an object that references itself (directly or through children).
Converting circular structure to JSONcyclic object value 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
- Stringify only the fields you need
- Use a replacer that skips seen objects
- Use util.inspect or console.dir for logging
Detailed fix by platform
JavaScript
- 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
- Object — Which object (the message names the path)?
- 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:
Similar errors
- entity.parse.failed API Error: Malformed JSON in request body (entity.parse.failed / JSON parse error)
- InvalidDefinitionException com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class X and no properties discovered
- is an invalid start of a value System.Text.Json: '<' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0
Most viewed in JavaScript
- TypeError TypeError: Cannot read properties of undefined (reading 'x')
- Failed to fetch TypeError: Failed to fetch / NetworkError when attempting to fetch resource
- module MIME type Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html"
Other ways to find it
Where this error sits
Origin: On your device. Errors that are often confused with or caused by this one (click to open):
🧠 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.
Report a correction or suggest an improvement
Last updated 13 Oct 2026