The first thing to accept is that nothing in the JSON specification represents a date. JSON has objects, arrays, strings, numbers, true, false, and null. That is the whole list. So when you stringify a JavaScript Date, the serializer quietly converts it to a string first, using the Date toJSON method, which produces an ISO 8601 timestamp in UTC. A Date built from June 15, 2026 at 2:30 in the afternoon local time becomes "2026-06-15T12:30:00.000Z" if your local offset is two hours ahead of UTC. The time is the same instant. The text looks different, and that difference is where most of the trouble starts.
Parsing does not undo the conversion. JSON.parse has no way to know that a particular string was once a Date, so it hands you back a string, and your code then does string things with it. Comparisons sort alphabetically, which happens to work for ISO timestamps but fails for every other format. Subtracting two date strings gives you NaN. Calling .getFullYear() on a string throws. The fix on the reading side is the reviver, the optional second argument to JSON.parse, which runs on every value and lets you convert strings that match a date pattern back into Dates:
const reviver = (key, value) => {
if (typeof value === "string" && /^\d{4}-\d{2}-\d{2}T/.test(value)) {
const d = new Date(value);
return isNaN(d) ? value : d;
}
return value;
};
const data = JSON.parse(text, reviver);
Keep the reviver narrow. A pattern that converts every string shaped like a date will also convert product codes, version strings, and identifiers that happen to look like timestamps. I match on specific keys I expect to hold dates, like createdAt or startsAt, and leave everything else alone. A reviver that guesses is a bug waiting for a sufficiently date shaped SKU.
How to handle dates in JSON without the midnight shift
The nastiest version of this bug is the day off error, and it needs no exotic setup. Take a date only value, a birthday or a holiday, and store it as a full timestamp at midnight. If that midnight is interpreted in UTC and then displayed in a timezone behind UTC, the date rolls back a day. A user in New York sees December 24 for a December 25 event. The data was never wrong. The instant was never wrong. The mistake was representing a calendar date as an instant in the first place.
My rule is blunt and it has held up: instants travel as ISO 8601 UTC strings with the Z suffix, and calendar dates travel as plain YYYY-MM-DD strings with no time component at all. Do not convert a calendar date into a Date object at midnight just to serialize it, because the serializer will attach a timezone interpretation you never asked for. Keep it a string end to end, and only parse it for display, in the user's local calendar, never through a UTC conversion.
Two more formats deserve a warning. Locale strings like 6/15/2026 are ambiguous across countries and painful to parse reliably, so they should never cross an API boundary. Epoch milliseconds are compact and unambiguous, but they are unreadable in logs and they invite a classic factor of 1000 error when one side sends seconds and the other expects milliseconds. If you inherit an API that sends epoch seconds, convert at the boundary, document it in one place, and never let both units circulate in the same codebase.
Python developers meet the mirror image of this problem. Python's json module refuses to serialize a datetime at all and raises TypeError, which is arguably more honest than JavaScript's silent conversion. The standard fix is a default function that converts datetimes to ISO strings on the way out, and the same reviver style thinking on the way back in. Either way, the contract belongs in your API documentation, not in tribal knowledge: dates are ISO 8601 UTC strings, date only values are YYYY-MM-DD, and nothing else is accepted.
One question I keep coming back to is whether the newer Temporal API changes any of this. It fixes a lot about Date itself, immutability and real timezone support, but it does not change JSON. A Temporal object still serializes to an ISO string and still parses back as a string unless you revive it. Better date objects, same boundary problem. The boundary is the work, and it always will be.
Paste a payload with mangled dates into the JSON repair tool to see exactly what your serializer produced, then fix the format at the source instead of patching every display.
Try it free, right in your browser.
Frequently asked questions
Does JSON have a date type?
No. JSON has strings, numbers, booleans, null, arrays, and objects. Dates are always sent as strings or numbers, and both sides must agree on the format.
Why does JSON.parse return a string instead of a Date?
Because JSON.parse only knows the JSON types. It cannot tell a date string from any other string, so you need a reviver function to convert date strings back into Date objects.
Why does my date show a day early after JSON round trip?
A date only value stored as a midnight UTC timestamp shifts backward when displayed in a timezone behind UTC. Store calendar dates as plain YYYY-MM-DD strings with no time component.
Should I send dates as ISO strings or epoch milliseconds?
ISO 8601 UTC strings for most APIs: readable, sortable, and unambiguous. Epoch milliseconds are fine internally but invite seconds versus milliseconds errors across teams.
What is a JSON.parse reviver?
An optional function passed as the second argument to JSON.parse. It runs on every key and value, so you can detect date strings and return real Date objects instead.
Get one practical guide a week: subscribe to the newsletter.
Related reading: The trailing comma that breaks your JSON · Why your JSON is double encoded · JSON with comments (JSONC)