Free · Fast · Privacy-first

Format JSON for Debugging, See Past [object Object]

Every JavaScript developer has logged an object and seen [object Object] staring back at them.

Reveals full object structure instantly

🔒

Spot null, undefined, and wrong types

No console.log juggling needed

Works for any JSON data source

Cost
Free forever
Sign-up
Not required
Processing
In your browser
Privacy
Files stay local
FreeNo signupWhite-label

Add this JSON Formatter to your website

Drop the JSON Formatter into any page — blog post, product docs, intranet, school portal — with a single line of HTML. Your visitors get the full tool, processed entirely in their browser. No backend, no uploads, no signup.

  • Files stay 100% in the visitor's browser
  • Responsive — adapts to any container width
  • Free forever, no API key needed

Embed code

<iframe
  src="https://www.fixtools.io/json/json-formatter?embed=1"
  width="100%"
  height="780"
  frameborder="0"
  style="border:0;border-radius:16px;max-width:900px;"
  title="JSON Formatter by FixTools"
  loading="lazy"
  allow="clipboard-write"
></iframe>

Attribution-friendly: a small "Powered by FixTools" link appears in the embed footer.

Why [object Object] Appears and How Formatting Solves It

In JavaScript, when you concatenate an object with a string or pass it to a function expecting a string, the engine calls the object's toString() method. The default toString() on plain objects returns "[object Object]". This happens in template literals, string concatenation, and some logging frameworks that stringify their arguments before writing them to a log sink. The actual data is still present in memory; the display mechanism is simply using the wrong serialization method. The fix is to explicitly convert the object to a JSON string before displaying it, so the full structure becomes readable text.

The correct pattern for logging a JavaScript object's complete structure is console.log(JSON.stringify(obj, null, 2)), which converts the object to a formatted JSON string with 2-space indentation. If the object has already been serialized to a JSON string by an API client, a database driver, or a message queue consumer, you already have a raw JSON string that can be copied directly. In either case, pasting the resulting JSON into FixTools produces the full structure with syntax highlighting, making it far easier to identify a field with an unexpected value than reading a dense monospaced console output line-by-line.

Debugging with formatted JSON delivers the most value when data has more than two or three nesting levels. A flat object with five keys is easy to read in any form. An API response with arrays of objects, each containing nested sub-objects and further arrays, is nearly impossible to read unformatted. Proper indentation aligns each key to its nesting level, making parent-child relationships between fields visually obvious. It becomes straightforward to confirm that a specific path like response.data.items[0].user.address.city exists, has the right type, and contains the expected value without writing a test first.

Several spec edge cases surface specifically during debugging. JavaScript serialises Date objects to ISO 8601 strings via the Date.prototype.toJSON method, but the parsed JSON does not contain a Date type, so the round-tripped value is a string and any code expecting a Date instance throws. Large integers beyond Number.MAX_SAFE_INTEGER (2^53 - 1) lose precision silently: a Twitter or Stripe identifier like 9007199254740993 becomes 9007199254740992 when round-tripped through JSON.parse and JSON.stringify. Trailing commas, comments, and NaN are not allowed in strict JSON, so when JSON.stringify(obj) silently omits a field, the source object likely had undefined, a function, or a Symbol value at that key, none of which are representable in JSON. Knowing these edge cases turns mysterious bugs into one-line diagnoses.

Debugging workflows benefit from pairing the formatter with structured logging conventions. Pino, Bunyan, and Winston emit one JSON object per log line, where each object includes a timestamp, log level, message, and arbitrary context fields. To investigate a specific request, copy the relevant log lines, paste them into FixTools one at a time (each line is its own document), and read the formatted view of each. For Kubernetes pods, kubectl logs piped through grep extracts the lines of interest, and FixTools formats the JSON payload of any single line for human inspection. This pattern scales from local development to production incident investigation because the same log format works at every tier, and the debugging tool stays the same regardless of where the log originated.

How to use this tool

💡

Paste any JSON string you are trying to debug here. The formatter reveals the full structure with indentation so you can trace the exact field causing an issue.

How It Works

Step-by-step guide to format json for debugging, see past [object object]:

  1. 1

    Get the JSON string

    Serialize the object you are debugging with JSON.stringify(obj) in your console, or copy the raw JSON directly from a log file, API response capture, or network request body. If the value is already a JSON string, copy it as-is. You do not need to strip surrounding quotes, FixTools accepts both raw strings and JSON text.

  2. 2

    Paste into FixTools

    Open FixTools in your browser and paste the JSON string into the formatter input area. The input accepts any valid JSON, regardless of how it was captured. If the string was logged with extra surrounding text, strip that text first so the input starts with an opening brace or bracket.

  3. 3

    Click Format

    Click the Format button. FixTools validates the JSON, then re-serializes it with 2-space indentation and syntax highlighting. If the JSON is invalid, the error position is shown instead. If the JSON is valid, the structured output appears immediately, coloured by token type so you can distinguish strings, numbers, booleans, and null at a glance.

  4. 4

    Inspect the structure

    Scroll through the formatted output to find the field or value causing the bug. Use Ctrl+F or Cmd+F to search for a specific key name. Count indentation levels to understand nesting depth. Look for null, missing keys, or unexpected value types. The visual structure makes parent-child relationships between keys immediately obvious in a way raw minified text cannot.

Real-world examples

Common situations where this approach makes a real difference:

React developer

Formatted JSON makes null values and missing fields visible at a glance.

Node.js developer

Extra nesting layers are easy to miss in minified output but obvious when formatted.

Backend developer

Parallel error fields in API responses are frequently missed without formatting.

Junior developer

Formatting JSON is one of the first debugging skills developers learn when working with APIs.

Pro tips

Get better results with these expert suggestions:

1

Use console.log(JSON.stringify(obj, null, 2)) instead of console.log(obj)

console.log(obj) in browsers shows an interactive expandable object that reflects the live state of the object at the time you inspect it, not the state at the time of logging. This causes a confusing debugging experience where an object looks different when expanded versus when it was first logged. JSON.stringify(obj, null, 2) captures the exact state at log time as an immutable string, preventing this mismatch and giving you a reliable snapshot for debugging.

2

Breakpoint and JSON.stringify in DevTools

When paused at a breakpoint in Chrome or Firefox DevTools, type JSON.stringify(variableName, null, 2) in the console to see the full serialized state of any variable currently in scope. This is faster than stepping through the watch panel for deeply nested objects. You can also copy the output directly from the console to paste into FixTools for a syntax-highlighted, searchable view.

3

Check for undefined vs null carefully

JSON.stringify converts undefined values to null in arrays but omits keys with undefined values from objects entirely. If a field you expect is missing from your formatted output, the original object likely had that key set to undefined rather than null. A key present with a null value appears as null in the output. A key set to undefined is simply absent. This distinction is critical when debugging missing data bugs in JavaScript applications.

4

Log request and response together for API debugging

When debugging an API integration, log both the outgoing request body and the incoming response body as JSON strings using JSON.stringify. Format both in FixTools and compare them side by side. Field names that change between the request and response (such as camelCase in the request becoming snake_case in the response) are easy to miss in raw text but obvious when both sides are formatted and you can scan them visually.

FAQ

Frequently asked questions

JavaScript's default object-to-string conversion returns "[object Object]". This happens when an object is used in a string context: template literals, string concatenation, or console implementations that stringify their arguments before writing. To see the actual data, use console.log(JSON.stringify(obj, null, 2)) which converts the object to a readable formatted JSON string showing all fields, values, and nesting levels. Alternatively, console.dir(obj) shows an interactive expandable tree in most browser DevTools, though it reflects live state rather than a snapshot.
Use JSON.stringify(obj, null, 2) in your JavaScript code or browser console. The first argument is the object to serialize. The second is a replacer (null includes all properties). The third is the indentation width (2 produces readable 2-space indented output). The result is a plain string you can log, copy, or paste into FixTools for further inspection with syntax highlighting. For objects with circular references, use a library like flatted first.
If you serialize a JavaScript object to JSON and a field does not appear in the output, the field likely had an undefined value. JSON.stringify omits properties with undefined values from objects entirely, but converts undefined to null in arrays. A field set to null appears in the output as null. A field set to undefined is absent from the output entirely. This distinction is critical when debugging missing data: a missing key means undefined in the source object; a key present with null means explicitly null.
Paste the JSON into FixTools and use the browser's Ctrl+F or Cmd+F to search for the specific key name you are investigating. Count the indentation level to understand the nesting depth and parent-child relationships. Use the JSON Viewer at fixtools.io/json/json-viewer to get a collapsible tree view where you can expand and collapse individual branches. For programmatic access or extraction, use jq in a terminal: jq '.path.to.field' data.json extracts a value by its full path.
Yes. If your log file contains JSON strings (one per line or embedded in structured log entries), copy the JSON portion and paste it into FixTools. If the log line has a prefix (a timestamp, log level, or service name) before the JSON, remove the prefix first. Most structured logging formats write the JSON after a fixed-width prefix, so identify where the JSON begins by looking for the first opening brace or bracket character, then copy from that point onward.
Capture the exact JSON string that caused the parsing failure from the request body, a log file, or a database record and paste it into FixTools. The formatter validates the input and either produces clean formatted output (confirming the JSON is syntactically valid) or shows you the exact character position of the syntax error. This tells you immediately whether the problem is a malformed JSON string that cannot be parsed, or a valid JSON string with unexpected data values that require logic-level debugging.
After formatting in FixTools, press Ctrl+F or Cmd+F to open the browser find dialog and search for the key name or value you are looking for. For nested paths, search for the leaf key name first and then check the parent objects around it to confirm the nesting level. For programmatic searching from a terminal, use jq: echo '...' | jq '.path.to.key' extracts a value by its full dot-notation path. For filtering arrays, jq '.[] | select(.field == "value")' extracts matching elements.
No. JSON.stringify throws a TypeError when the object has a circular reference (where an object contains a reference back to itself or to one of its ancestors). JSON does not support circular structures because it is a linear text format. Remove the circular reference before serializing, or use a library like flatted or circular-json that handles circular structures by replacing cycles with a reference notation. FixTools can display the resulting text but will flag it as non-standard JSON since the reference notation is not valid RFC 8259.
Browser rendering is the slow step, not parsing. A 5MB JSON document parses in milliseconds but expanding it to a syntax-highlighted DOM with hundreds of thousands of styled nodes can lock the main thread for seconds. The fastest workaround during debugging is to slice the payload first: copy the first complete record from a top-level array and format only that excerpt to learn the schema, then jq against the full file for path-specific queries. For Node.js debugging, write the payload to a temp file with fs.writeFileSync and open it in VS Code rather than dumping into console output. console.dir(obj, {depth: null, colors: true}) is also faster than stringify for one-off inspection because it avoids producing a giant intermediate string.
Debug formatting prioritises human readability with 2-space indentation, full key names, and complete value expansion. Production logging prioritises machine ingestion: single-line JSON per log entry so a log aggregator like Datadog, Splunk, or Loki can index each record as one structured event. Mixing the two patterns hurts both audiences: pretty-printed logs become unparseable to aggregators because multi-line entries are treated as separate records, and minified debug output is unreadable for humans. The convention most teams settle on is structured single-line JSON for log files, with developers using a local jq or FixTools pass to pretty-print specific entries when investigating a failure. Pino, Bunyan, and Winston follow this pattern by default.

Ready to get started?

Open the full JSON Formatter — free, no account needed, works on any device.

Open JSON Formatter →

Free · No account needed · Works on any device