Are you sure that it is this conversion step and not the transport of the JSON to the browser?
There are two alternatives to consider:
1 - Instead of storing the data in the div (which requires network transport), you could also try saving it on the disk. Here is an example: Capture window/tab closing event - #2 by chriddyp
2. If you are saving it to the disk, perhaps instead of encoding as JSON, encoding as feather would be faster. See Apache Arrow and Dash - Community Thread for a discussion