JSON numbers that arrive as strings (and quietly break your UI)
Why APIs send "42" instead of 42, how to spot the mismatch in a viewer, and what to do in JavaScript and typed clients before the bug ships.
I have lost count of how many "impossible" UI bugs were a stringly-typed number. The label shows 42. The badge shows 42. The sum shows 4210 because someone wrote total + next and JavaScript concatenated. Validators smile the whole time. This post is about spotting that class of bug early and deciding whether to fix the producer or harden the consumer.
What it looks like in the wild
Legacy platforms, form posts, and CSV-to-JSON pipelines love strings. So do some mobile clients that stringify everything for "safety." You end up with payloads like the one below. A human reading the pretty-printed text often misses the quotes around the amounts.
{
"orderId": "A-1001",
"subtotal": "59.90",
"tax": "5.99",
"paid": "true"
}How to see it without squinting
In a structured viewer, string values and number values are usually styled or typed differently. In a table, scan the column: if every cell is left-aligned like text, or if a type chip says string, you have your answer. In raw text, train yourself to look for quotes around values that should be numeric or boolean.
Note that "true" is a string, not a boolean. Conditionals that check === true will fail while checks that rely on truthiness may pass for the wrong reason.
Fix the producer when you can
If you own the API, emit real numbers and booleans. Document the types. Add a contract test that fails when a money field is a string. That is the durable fix. Converting in every client guarantees someone will forget.
If you do not own the API, normalize at the boundary: parse once into a typed object, and never let the rest of the app see the raw strings. Half-parsed models are how the bug spreads.
A quick check while debugging
Paste the response, format it, open the record in Cards or Table, and confirm the type of every field involved in math or boolean logic. If you are comparing a fixture to a live response, look specifically for fields that flipped from number to string between versions — that shows up cleanly in a structural diff.
View My JSON will not replace a schema validator, but it will make the quotes visible before you dig into Redux.