You upload orders.json with 5,000 records and ask “what is the median order value for customers in California?” Instead of writing pandas code, ChatGPT eyeballs the first few thousand characters and replies “based on a sample of the data, the median appears to be around $80.” That answer was vibes, not math. The model treated the JSON as prose rather than triggering Code Interpreter to actually parse and aggregate. The result looks confident, contains a number, and is wrong.
The root cause is that ChatGPT decides whether to open a file in code or read it as context. JSON often gets routed to “read as context” — especially when the file is small enough to fit in the prompt or when your question reads like a summarization request. This article explains how to force the right path.
Common causes
Ordered by hit rate, highest first.
1. File fits in context, model never invokes Code Interpreter
If the JSON is under roughly 200 KB, the model often inlines it into the prompt and reasons over it as text. No Python runs. Aggregates like median, percentile, group-by are eyeball estimates.
How to spot it: ChatGPT does not show a “Analyzing” or code block. Reply lacks numerical precision. Asking “show the Python you used” gets “I estimated from the data” instead of code.
2. Question is phrased as a summary, not a calculation
“Tell me about this data” or “what are the main patterns” reads as summarization. The model picks the cheap path — read top-of-file and describe. Quantitative phrasing triggers code; qualitative phrasing does not.
How to spot it: Reworded as “compute the median in Python and show the code” triggers Code Interpreter; the original “what is typical” did not.
3. JSON has irregular shape, model gives up on structure
Records have inconsistent keys, deeply nested with optional fields, or a mix of arrays and objects at the root. The model recognizes it cannot trivially map this to a table and falls back to text reading.
How to spot it: Schema inspection of your file reveals optional / nested / inconsistent fields. ChatGPT replies hedge with “this dataset has varying structure” then make qualitative claims.
4. NDJSON / JSON Lines uploaded with .json extension
Your file is one JSON object per line (NDJSON), but the extension is .json. json.load() fails. Code Interpreter, if invoked, raises a parse error and the model recovers by reading the raw bytes as text.
How to spot it: First character is { and the second line also starts with { — that is NDJSON, not JSON. json.load() on it fails; pd.read_json(..., lines=True) works.
5. JSON is in a Project / Custom GPT knowledge file
Knowledge files in Projects and Custom GPTs go through vector embedding, not Code Interpreter. Queries against them retrieve fragments — they are never aggregated as numbers.
How to spot it: The JSON was uploaded once at Project setup. It does not appear as a per-message attachment. Aggregate questions return retrieved snippets, not totals.
6. Model is in a mode without Code Interpreter
Voice mode, certain mobile flows, and some Custom GPTs ship without Code Interpreter enabled. Numerical answers on data files in those modes are always estimates.
How to spot it: Custom GPT config does not list Code Interpreter under Capabilities. Or you are in a chat without the paperclip-plus-tools menu showing “Code Interpreter.”
7. Token budget hit, file truncated silently
Large JSON inlined into prompt: only the first N tokens make it through. Records past the cutoff do not exist to the model. Aggregates are computed on the visible portion only.
How to spot it: Ask “how many records are in this file?” If the answer is suspiciously round (like “approximately 1,000”) and your real count is different, truncation happened.
Shortest path to fix
Step 1: Ask for Python explicitly
Replace “what is the median order value” with:
Load
orders.jsoninto a pandas DataFrame using Code Interpreter. Compute the median of thetotalfield grouped bystate. Show me the code and the resulting table.
This phrasing forces the tool-call. The model rarely refuses an explicit Code Interpreter request when the tool is available.
Step 2: If it is NDJSON, say so
This file is NDJSON (one JSON object per line). Load it with
pd.read_json('orders.json', lines=True).
Hand-feeding the parse line removes the parse-failure branch entirely.
Step 3: Validate row count first
Always ask:
First, print
len(df)anddf.dtypes. Confirm you read all rows before answering.
A row count mismatch versus your expectation surfaces truncation, NDJSON misreads, or duplicate parses.
Step 4: For nested JSON, flatten before aggregation
import json, pandas as pd
with open('orders.json') as f:
data = json.load(f)
df = pd.json_normalize(data, sep='_')
json_normalize collapses nested keys into flat columns. After that, group-by and aggregates work like any CSV.
Step 5: For Project / Custom GPT knowledge, switch to per-message upload
If you need aggregate answers, do not put the JSON in Knowledge. Upload it as a per-message attachment in the chat where Code Interpreter is active. Knowledge is for retrieval, not arithmetic.
Step 6: Reserve Knowledge for reference text, not data
Schema guidelines, taxonomies, brand copy — those belong in Project Knowledge. Tabular data that needs counted, filtered, summed — those belong as per-chat attachments.
Step 7: Verify the answer with a known total
Pick a value you can cross-check (the count of records, the sum of a small column, a specific known record). Ask ChatGPT to compute it and compare. If it matches, trust the aggregates. If it does not, dig into which step diverged.
When this is not on you
The decision whether to invoke Code Interpreter is opaque. OpenAI tunes the trigger heuristics and they shift between models. A prompt that triggered code last month may not this month. The only stable defense is to ask for code explicitly.
Vector-embedded Knowledge stores are also fundamentally not arithmetic engines. If the product surface routes your file there, you cannot retro-add aggregation through prompting.
Easy to misdiagnose as
- “ChatGPT is bad at math” — it is not when Python runs. It is bad at math when it is reading prose.
- “The file is too big” — files under a few MB are well within Code Interpreter’s reach. The issue is invocation, not size.
- “The JSON is malformed” — usually not. Validate with
jq . orders.json > /dev/nullfirst; ifjqis happy, the file is fine. - “Custom GPT instructions are not working” — instructions cannot force tool calls reliably; the model still routes based on the question.
Prevention
- Default to “compute X with Code Interpreter and show the code” phrasing for any quantitative question on a file.
- Keep a one-line preflight: “Print row count, column names, and dtypes before answering.”
- Never put aggregable data in Project Knowledge. Knowledge is a search index, not a database.
- Use
.ndjsonextension for line-delimited JSON so the format is unambiguous. - For complex schemas, pre-flatten to CSV locally with
jqor pandas; upload the flat CSV. Less for the model to figure out.
FAQ
- Why does CSV work but JSON does not? CSV almost always triggers Code Interpreter — flat, tabular, obvious. JSON is ambiguous; small JSON especially often lands in the read-as-context path.
- Can I make Custom GPT always use Code Interpreter? Enable the capability in config and write the system prompt to require code for any analytical question. Even then, the model occasionally skips it on edge cases.
Related
- ChatGPT csv column misread
- ChatGPT data file analysis wrong
- ChatGPT spreadsheet too large truncated
- ChatGPT file analysis too shallow
- ChatGPT large document incomplete analysis
- ChatGPT excel formula not evaluated
- ChatGPT multiple files not used together
- ChatGPT project vector search misses
- ChatGPT project files not referenced
- ChatGPT file type unsupported
- ChatGPT zip archive not extracted
- ChatGPT generated file download failed
Tags: #ChatGPT #ChatGPT files #Troubleshooting #Debug #json #Data analysis #code-interpreter